src/DoctrineModule/Service/CacheFactory.php
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /** @var $options \DoctrineModule\Options\Cache */
        $options = $this->getOptions($serviceLocator, 'cache');
        $class   = $options->getClass();

        if (!$class) {
            throw new RuntimeException('Cache must have a class name to instantiate');
        }

        $instance = $options->getInstance();

        if (is_string($instance) && $serviceLocator->has($instance)) {
            $instance = $serviceLocator->get($instance);
        }

        switch ($this->name) {
            case 'filesystem':
                $cache = new $class($options->getDirectory());
                break;

            case 'predis':
                $cache = new $class($instance);
                break;

            default:
                $cache = new $class;
        }

        if ($cache instanceof MemcacheCache) {
            /* @var $cache MemcacheCache */
            $cache->setMemcache($instance);
        } elseif ($cache instanceof MemcachedCache) {
            /* @var $cache MemcachedCache */
            $cache->setMemcached($instance);
        } elseif ($cache instanceof RedisCache) {
            /* @var $cache RedisCache */
            $cache->setRedis($instance);
        }

        if ($cache instanceof CacheProvider && ($namespace = $options->getNamespace())) {
            $cache->setNamespace($namespace);
        }

        return $cache;
    }
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /** @var $options \DoctrineModule\Options\Cache */
        $options = $this->getOptions($serviceLocator, 'cache');
        $class   = $options->getClass();

        if (!$class) {
            throw new RuntimeException('Cache must have a class name to instantiate');
        }

        $instance = $options->getInstance();

        if (is_string($instance) && $serviceLocator->has($instance)) {
            $instance = $serviceLocator->get($instance);
        }

        switch ($this->name) {
            case 'filesystem':
                $cache = new $class($options->getDirectory());
                break;

            case 'predis':
                $cache = new $class($instance);
                break;

            default:
                $cache = new $class;
        }

        if ($cache instanceof MemcacheCache) {
            /* @var $cache MemcacheCache */
            $cache->setMemcache($instance);
        } elseif ($cache instanceof MemcachedCache) {
            /* @var $cache MemcachedCache */
            $cache->setMemcached($instance);
        } elseif ($cache instanceof RedisCache) {
            /* @var $cache RedisCache */
            $cache->setRedis($instance);
        }

        if ($cache instanceof CacheProvider && ($namespace = $options->getNamespace())) {
            $cache->setNamespace($namespace);
        }

        return $cache;
    }
{@inheritDoc}

@return \Doctrine\Common\Cache\Cache

@throws RuntimeException