public static function init($connector = null)
    {
        $classMap  = [Files::class, Redis::class, Memcache::class, Memcached::class];
        $driverMap = ['files', 'redis', 'memcache', 'memcached'];

        if (is_null($connector)) {
            $connector = new Files();
        } elseif (is_array($connector)) {
            $driver = $connector['driver'];
            if (!in_array($driver, $driverMap)) {
                throw new CacheException('unknown cache driver: '.$driver);
            }
            $class     = 'easySwoole\\Cache\\Connector\\'.ucfirst($driver);
            $connector = new $class($connector);
        } elseif (is_object($connector)) {
            $className = get_class($connector);
            if (!in_array($className, $classMap)) {
                throw new CacheException('unknown cache driver: '.$className);
            }
        } else {
            throw new CacheException('cache driver options invalid');
        }

        self::$connector = $connector;
    }
public static function init($connector = null)
    {
        $classMap  = [Files::class, Redis::class, Memcache::class, Memcached::class];
        $driverMap = ['files', 'redis', 'memcache', 'memcached'];

        if (is_null($connector)) {
            $connector = new Files();
        } elseif (is_array($connector)) {
            $driver = $connector['driver'];
            if (!in_array($driver, $driverMap)) {
                throw new CacheException('unknown cache driver: '.$driver);
            }
            $class     = 'easySwoole\\Cache\\Connector\\'.ucfirst($driver);
            $connector = new $class($connector);
        } elseif (is_object($connector)) {
            $className = get_class($connector);
            if (!in_array($className, $classMap)) {
                throw new CacheException('unknown cache driver: '.$className);
            }
        } else {
            throw new CacheException('cache driver options invalid');
        }

        self::$connector = $connector;
    }
public static function init ( $ connector = null ) { $ classMap = [ Files :: class , Redis :: class , Memcache :: class , Memcached :: class ] ; $ driverMap = [ 'files' , 'redis' , 'memcache' , 'memcached' ] ; if ( is_null ( $ connector ) ) { $ connector = new Files ( ) ; } elseif ( is_array ( $ connector ) ) { $ driver = $ connector [ 'driver' ] ; if ( ! in_array ( $ driver , $ driverMap ) ) { throw new CacheException ( 'unknown cache driver: ' . $ driver ) ; } $ class = 'easySwoole\\Cache\\Connector\\' . ucfirst ( $ driver ) ; $ connector = new $ class ( $ connector ) ; } elseif ( is_object ( $ connector ) ) { $ className = get_class ( $ connector ) ; if ( ! in_array ( $ className , $ classMap ) ) { throw new CacheException ( 'unknown cache driver: ' . $ className ) ; } } else { throw new CacheException ( 'cache driver options invalid' ) ; } self :: $ connector = $ connector ; }
Cache handle initialize
Cache constructor.
@param $connector
@throws CacheException
Cache handle initialize Cache constructor .