Libmemcached缓存

@return Libmemcached
775669
private function createLibmemcachedCache():Libmemcached
    {
        /** @var IConfig $config */
        $config = $this->di->getShared('config');
        /** @var IApp $app */
        $app = $this->di->getShared('app');
        $lifetime = (int)$config->get($this->getName() . '.lifetime', 3600);
        $servers = $config->get($this->getName() . '.servers');
        $frontCache = new FrontData([
            "lifetime" => $lifetime
        ]);
        return $cache = new Libmemcached(
            $frontCache,
            [
                "servers" => $servers,
                "client" => [
                    \Memcached::OPT_HASH => \Memcached::HASH_MD5,
                    \Memcached::OPT_PREFIX_KEY => $app->getAppId()
                ]
            ]
        );
    }
648236
private function cachedAllPerStore() {
		if (!isset($this->{__METHOD__})) {
			$this->{__METHOD__} = array_merge($this->cachedI(), $this->cachedObjectsI());
		}
		return $this->{__METHOD__};
	}
872453
public function getCacheDirectory()
    {
        $dir = $this->cacheBaseDir.'/RatingServicesCache/';
        if (!file_exists($dir)) {
            mkdir($dir, 0777, true);
            if (!file_exists($dir)) {
                $dir = null;
            }
        }
        if (!is_dir($dir) || !is_writable($dir)) {
            $dir = null;
        }

        return $dir;
    }
160688
private function getCached()
    {
        $syntax = "// Cached assets do not modify\r\nlet cache = [" . PHP_EOL;

        foreach ($this->getCachedFiles() as $file) {
            $syntax .= "'$file'," . PHP_EOL;
        }

        $syntax .= "];";

        return $syntax;
    }
351977
protected function createMemcacheDriver()
    {
        $serverArray    = $this->config['servers'];
        $persistent     = boolval($this->config['persistent']);
        $name           = trim($this->config['server_name']);
        $prefix         = trim($this->config['prefix']);
        $expireTime     = intval($this->config['lifetime']);

        if ($persistent && (strlen($name) > 0)) {
            $memcached  = new Memcached($name);
        } else {
            $memcached  = new Memcached();
        }

        if (!sizeof($memcached->getServerList())) {
            $memcached->addServers($serverArray);
        }

        $store = new MemcachedStore($memcached, $prefix);
        return new CacheSessionHandler($store, $expireTime);
    }
68643
public function getCacheDir()
    {
        if ($this->cacheDir === null) {
            $this->setCacheDir(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR);
        }

        return $this->cacheDir;
    }
101753
private function getDefaultCacheAdapter()
    {
        return new FileSystemCacheAdapter(
            $this->config->getCachePath(),
            $this->config->getFileLock(),
            $this->config->getMinCacheFileSize()
        );
    }
534974
public static function init()
    {
        // !self::$_instance instanceof self
        if (!isset(self::$instance)) {
            self::$instance = new self();

            // 使用哪种方式的cache
            $cache_driver = Config::get('cache_driver');

            // 兼容predis(PHP扩展), phpredis(C扩展)
            $type = $cache_driver;
            if ($cache_driver === 'predis') {
                $cache_driver = 'redis';
            }

            $cache_driver = '\\ePHP\Cache\\' . ($cache_driver ? 'Cache' . ucfirst($cache_driver) : 'CacheFile');
            self::$instance->handle = new $cache_driver($type);
        }
        return self::$instance;
    }
493241
protected function cachePool()
    {
        if ($this->cachePool === null) {
            throw new RuntimeException(sprintf(
                'Cache Pool is not defined for "%s"',
                get_class($this)
            ));
        }

        return $this->cachePool;
    }
617479
public function clearCache()
    {
        if (!empty($this->schema))
        {
            $this->schema->clearCache();
        }

        $this->dao = [];
        $this->schema = null;
        return $this;
    }
372871
public function getCache()
    {
        if (!isset($this->config['cache'])) {
            throw new InvalidArgumentException('A "cache" file system must be set.');
        }

        if (is_string($this->config['cache'])) {
            return new Filesystem(
                new Local($this->config['cache'])
            );
        }

        return $this->config['cache'];
    }
951496
public function getCache()
    {
        if (null === $this->cache) {
            if (isset($this->options['cache']) && is_string($this->options['cache'])) {
                $this->cache = $this->container->get($this->options['cache']);
            }
        }
        
        return $this->cache;
    }
1319804
public function getCacheDir() {
        if (is_null($this->__project_cache_dir)) {
            $this->__project_cache_dir = new File("." . uniqid(), $this->projectRootDir->getAbsolutePath());
        }
        return $this->__project_cache_dir;
    }
949483
protected function cache()
    {
        return method_exists($this->cache, 'tags') ? $this->cache->tags($this->tag) : $this->cache;
    }
1256769
public function clearCache()
    {
        if ($this->Using === 'APCu') {
            return $this->Modified = apcu_clear_cache();
        }
        if ($this->Using === 'Memcached') {
            return ($this->WorkingData->flush() && ($this->Modified = true));
        }
        if ($this->Using === 'Redis') {
            return ($this->WorkingData->flushDb() && ($this->Modified = true));
        }
        if ($this->Using === 'PDO') {
            $PDO = $this->WorkingData->prepare(self::clearQuery);
            if ($PDO !== false && $PDO->execute()) {
                return ($PDO->rowCount() > 0 && $this->Modified = true);
            }
            return false;
        }
        if (is_array($this->WorkingData)) {
            $this->WorkingData = [];
            return $this->Modified = true;
        }
        return false;
    }
664283
public function getCache()
    {
        $data = $this->memcache->get(
            $this->config['key_prefix'] .
            '.storage'
        );
        $this->isCached = !empty($data);

        return $data;
    }
600332
public function getByteCodeCache()
    {
        if (count($this->data) === 0) {
            return $this->byteCodeCache;
        }
        $mapper = new ArrayMapper();
        return $mapper->fromArray($this->data);
    }