/** * Create a new cache storage instance. * * @param string $storage * * @return CS\Apc|CS\Dba|CS\File|CS\Memcached|CS\Memory|CS\Pdo|CS\Redis|CS\WinCache * @throws \RuntimeException */ protected static function factory($storage) { $conf = Registry::get('conf'); switch ($storage) { case 'apc': return new CS\Apc($conf['cache']['key']); case 'file': return new CS\File($conf['cache']['storage_path']); case 'pdo': return new CS\Pdo(Pdo\Factory::get($conf['cache']['database']), $conf['cache']['key']); case 'memcached': return new CS\Memcached(Memcached::connection(), $conf['cache']['key']); case 'memory': return new CS\Memory(); case 'redis': return new CS\Redis(Redis::database()); case 'wincache': return new CS\WinCache($conf['cache']['key']); case 'dba': return new CS\Dba(String::ensureTrailing('/', $conf['cache']['storage_path']) . $conf['cache']['key']); default: throw new \RuntimeException("Cache storage {$storage} is not supported."); } }
/** * Delete an item from the cache. * * @param string $key */ public function forget($key) { $this->redis->del($key); }