protected function diCache($configKey, $prefix = 'eva_')
{
$config = $this->getDI()->getConfig();
$adapterMapping = array('apc' => 'Phalcon\\Cache\\Backend\\Apc', 'file' => 'Phalcon\\Cache\\Backend\\File', 'libmemcached' => 'Phalcon\\Cache\\Backend\\Libmemcached', 'memcache' => 'Phalcon\\Cache\\Backend\\Memcache', 'memory' => 'Phalcon\\Cache\\Backend\\Memory', 'mongo' => 'Phalcon\\Cache\\Backend\\Mongo', 'xcache' => 'Phalcon\\Cache\\Backend\\Xcache', 'redis' => 'Phalcon\\Cache\\Backend\\Redis', 'wincache' => 'Phalcon\\Cache\\Backend\\Wincache', 'base64' => 'Phalcon\\Cache\\Frontend\\Base64', 'data' => 'Phalcon\\Cache\\Frontend\\Data', 'igbinary' => 'Phalcon\\Cache\\Frontend\\Igbinary', 'json' => 'Phalcon\\Cache\\Frontend\\Json', 'none' => 'Phalcon\\Cache\\Frontend\\None', 'output' => 'Phalcon\\Cache\\Frontend\\Output');
$frontCacheClassName = $config->cache->{$configKey}->frontend->adapter;
$frontCacheClassName = false === strpos($frontCacheClassName, '\\') ? strtolower($frontCacheClassName) : $frontCacheClassName;
$frontCacheClass = empty($adapterMapping[$frontCacheClassName]) ? $frontCacheClassName : $adapterMapping[$frontCacheClassName];
if (false === class_exists($frontCacheClass)) {
throw new Exception\RuntimeException(sprintf('No cache adapter found by %s', $frontCacheClass));
}
$frontCache = new $frontCacheClass($config->cache->{$configKey}->frontend->options->toArray());
if (!$config->cache->enable || !$config->cache->{$configKey}->enable) {
$cache = new \Eva\EvaEngine\Cache\Backend\Disable($frontCache);
} else {
$backendCacheClassName = $config->cache->{$configKey}->backend->adapter;
$backendCacheClassName = false === strpos($backendCacheClassName, '\\') ? strtolower($backendCacheClassName) : $backendCacheClassName;
$backendCacheClass = !empty($adapterMapping[$backendCacheClassName]) ? $adapterMapping[$backendCacheClassName] : $backendCacheClassName;
if (!class_exists($backendCacheClass)) {
throw new Exception\RuntimeException(sprintf('No cache adapter found by %s', $backendCacheClassName));
}
$cache = new $backendCacheClass($frontCache, array_merge(array('prefix' => $prefix), $config->cache->{$configKey}->backend->options->toArray()));
}
return $cache;
}