From f705653802e4981dcfc3336878f4be24fbdc3ab0 Mon Sep 17 00:00:00 2001 From: Thomas Metois Date: Mon, 7 Nov 2016 16:41:36 +0100 Subject: [PATCH] Cache zf conf & use doctrine cache service --- config/application.config.php-dist-BO | 9 ++++++- config/application.config.php-dist-FO | 9 ++++++- config/autoload/global.php | 35 +-------------------------- 3 files changed, 17 insertions(+), 36 deletions(-) diff --git a/config/application.config.php-dist-BO b/config/application.config.php-dist-BO index 5ce66d7..b7e2a90 100644 --- a/config/application.config.php-dist-BO +++ b/config/application.config.php-dist-BO @@ -5,6 +5,7 @@ * * @see https://github.com/zendframework/ZFTool */ +$env = getenv('APP_ENV') ?: 'production'; return array( 'modules' => array( 'DoctrineModule', @@ -19,6 +20,12 @@ return array( ), 'config_glob_paths' => array( 'config/autoload/{,*.}{global,local}.php' - ) + ), + 'config_cache_enabled' => ($env == 'production'), + 'config_cache_key' => 'c8aaaaa11586f8b1bf5565cc6064e70a', // md5('config_cache_key_monarc') + 'module_map_cache_enabled' => ($env == 'production'), + 'module_map_cache_key' => '664579376c4dcdcaa0bcdd0f7e7bf25b', // md5('module_map_cache_key_monarc'), + 'cache_dir' => 'data/cache/', + 'check_dependencies' => ($env != 'production'), ), ); diff --git a/config/application.config.php-dist-FO b/config/application.config.php-dist-FO index 85795ce..ee624df 100644 --- a/config/application.config.php-dist-FO +++ b/config/application.config.php-dist-FO @@ -5,6 +5,7 @@ * * @see https://github.com/zendframework/ZFTool */ +$env = getenv('APP_ENV') ?: 'production'; return array( 'modules' => array( 'DoctrineModule', @@ -19,6 +20,12 @@ return array( ), 'config_glob_paths' => array( 'config/autoload/{,*.}{global,local}.php' - ) + ), + 'config_cache_enabled' => ($env == 'production'), + 'config_cache_key' => 'c8aaaaa11586f8b1bf5565cc6064e70a', // md5('config_cache_key_monarc') + 'module_map_cache_enabled' => ($env == 'production'), + 'module_map_cache_key' => '664579376c4dcdcaa0bcdd0f7e7bf25b', // md5('module_map_cache_key_monarc'), + 'cache_dir' => 'data/cache/', + 'check_dependencies' => ($env != 'production'), ), ); diff --git a/config/autoload/global.php b/config/autoload/global.php index 4ec899c..e8fc108 100644 --- a/config/autoload/global.php +++ b/config/autoload/global.php @@ -14,40 +14,7 @@ return array( // 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.cache.mycache' => 'MonarcCore\Service\DoctrineCacheServiceFactory', ), ), 'doctrine' => array(