protected static function factory($storage)
    {
        $cache = Config::get('cache');

        switch ($storage) {
            case 'apc':
                return new CS\Apc($cache['key']);

            case 'file':
                return new CS\File($cache['storage_path']);

            case 'pdo':
                return new CS\Pdo(Pdo\Factory::get($cache['database']), $cache['key']);

            case 'memcached':
                return new CS\Memcached(Memcached::connection(), $cache['key']);

            case 'memory':
                return new CS\Memory();

            case 'redis':
                return new CS\Redis(Redis::database());

            case 'wincache':
                return new CS\WinCache($cache['key']);

            case 'dba':
                return new CS\Dba(Str::ensureTrailing('/', $cache['storage_path']) . $cache['key']);

            default:
                throw new \RuntimeException("Cache storage {$storage} is not supported.");
        }
    }