php - How to cache the application configs in memory in Zend Framework 2? -
one of must-haves performance optimization of zend framework 2 application caching of configurations. idea merge them 1 big config file (or 2 files, e.g. module-classmap-cache.php
, module-config-cache.php
), config files don't need opened , merged on every request. (see info in official documentation , how-to in article of rob allen "caching zf2 merged configuration"):
application.config.php
return [ 'modules' => [ ... ], 'module_listener_options' => [ ... 'config_cache_enabled' => true, 'config_cache_key' => 'app_config', 'module_map_cache_enabled' => true, 'module_map_cache_key' => 'module_map', 'cache_dir' => './data/cache', ], ];
i'd optimize bit more , load configs in-memory cache (e.g. apcu). provided framework? or have write functionality myself?
the caching mechanism implemented in configlistener
class of modulemanager
(source of write config & read config). can see there, supported caching method writing cached configuration file.
it instantiated default in defaultlisteneraggregate
(source), again hard coded in modulemanagerfactory
of mvc module (source).
in order replace own logic, have to:
- replace
configlistener
own (or @ least extend respective parts) - change
modulemanagerfactory
explicitly set ownconfiglistener
ondefaultlisteneraggregate
before gets lazy-created.
while feasible, don't think worth effort. merged config file php file, should cached opcache anyway. , opcache php-optimized in-memory cache. i'd expect faster all-purpose in-memory store.
Comments
Post a Comment