Gc\Mvc\Factory\CacheFactory::createService PHP Method

createService() public method

Create the cache storage apdater from the configuration.
public createService ( Zend\ServiceManager\ServiceLocatorInterface $serviceLocator ) : Zend\Cache\StorageFactory
$serviceLocator Zend\ServiceManager\ServiceLocatorInterface Service Manager
return Zend\Cache\StorageFactory
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $coreConfig = $serviceLocator->get('CoreConfig');
        $cacheTtl = (int) $coreConfig->getValue('cache_lifetime');
        $cacheHandler = $coreConfig->getValue('cache_handler');
        if (!in_array($cacheHandler, array('apc', 'memcached', 'filesystem'))) {
            $cacheHandler = 'filesystem';
        }
        switch ($cacheHandler) {
            case 'memcached':
                $namespace = preg_replace('/[^a-z0-9_\\+\\-]+/Di', '_', str_replace('/', '-', strtolower($coreConfig->getValue('site_name'))));
                $cacheOptions = array('ttl' => $cacheTtl, 'namespace' => $namespace, 'servers' => array(array('localhost', 11211)));
                break;
            case 'apc':
                $cacheOptions = array('ttl' => $cacheTtl);
                break;
            default:
                $cacheOptions = array('ttl' => $cacheTtl, 'cache_dir' => GC_APPLICATION_PATH . '/data/cache');
                break;
        }
        return CacheStorage::factory(array('adapter' => array('name' => $cacheHandler, 'options' => $cacheOptions), 'plugins' => array('exception_handler' => array('throw_exceptions' => false), 'Serializer')));
    }
CacheFactory