Doctrine add cache prod env

pull/1/head
Thomas Metois 2016-11-07 12:00:40 +01:00
parent 0034837ac5
commit 4e381e8ea5
1 changed files with 44 additions and 6 deletions

View File

@ -12,6 +12,44 @@
*/ */
return array( return array(
// DOCTRINE CONF // DOCTRINE CONF
'service_manager' => array(
'factories' => array(
'doctrine.cache.mycache' => function(\Zend\ServiceManager\ServiceManager $sm){
$arrayCache = new \Doctrine\Common\Cache\ArrayCache();
if(getenv('APPLICATION_ENV') == 'production'){
if(extension_loaded('apc')){
$apcCache = new \Doctrine\Common\Cache\ApcCache();
$chainCache = new \Doctrine\Common\Cache\ChainCache([$apcCache,$arrayCache]);
return $chainCache;
}elseif(extension_loaded('apcu')){
$apcuCache = new \Doctrine\Common\Cache\ApcuCache();
$chainCache = new \Doctrine\Common\Cache\ChainCache([$apcuCache,$arrayCache]);
return $chainCache;
}
// TODO: untested / add param for memchache(d) host & port
/*elseif(extension_loaded('memcache')){
$memcache = new \Memcache();
if($memcache->connect('localhost', 11211)){
$cache = new \Doctrine\Common\Cache\MemcacheCache();
$cache->setMemcache($mem);
$chainCache = new \Doctrine\Common\Cache\ChainCache([$cache,$arrayCache]);
return $chainCache;
}
}elseif(extension_loaded('memcached')){
$memcache = new \Memcached();
if($memcache->connect('localhost', 11211)){
$cache = new \Doctrine\Common\Cache\MemcachedCache();
$cache->setMemcached($mem);
$chainCache = new \Doctrine\Common\Cache\ChainCache([$cache,$arrayCache]);
return $chainCache;
}
}*/
}
return $arrayCache;
},
),
),
'doctrine' => array( 'doctrine' => array(
'connection' => array( 'connection' => array(
'orm_default' => array( 'orm_default' => array(
@ -71,9 +109,9 @@ return array(
), ),
'configuration' => array( 'configuration' => array(
'orm_default' => array( 'orm_default' => array(
'metadata_cache' => 'array', 'metadata_cache' => 'mycache',
'query_cache' => 'array', 'query_cache' => 'mycache',
'result_cache' => 'array', 'result_cache' => 'mycache',
'driver' => 'orm_default', // This driver will be defined later 'driver' => 'orm_default', // This driver will be defined later
'generate_proxies' => true, 'generate_proxies' => true,
'proxy_dir' => 'data/DoctrineORMModule/Proxy', 'proxy_dir' => 'data/DoctrineORMModule/Proxy',
@ -85,9 +123,9 @@ return array(
'second_level_cache' => array(), 'second_level_cache' => array(),
), ),
'orm_cli' => array( 'orm_cli' => array(
'metadata_cache' => 'array', 'metadata_cache' => 'mycache',
'query_cache' => 'array', 'query_cache' => 'mycache',
'result_cache' => 'array', 'result_cache' => 'mycache',
'driver' => 'orm_cli', // This driver will be defined later 'driver' => 'orm_cli', // This driver will be defined later
'generate_proxies' => true, 'generate_proxies' => true,
'proxy_dir' => 'data/DoctrineORMModule/Proxy', 'proxy_dir' => 'data/DoctrineORMModule/Proxy',