In a large scale web application, especially based on Zend Framework, there are lot’s of components that support built in cache support. Such are Zend_Db, Zend_Translate, Zend_Date, etc. Also you may need cache support wherever in the app, so my advice is to setup a cache instance in the “beginning”, into the bootstrap.php or even better – into a front controller plugin, and to store it into the Zend_Registry. Thus you’ve to change only the lifetime for specific needs:
<?php class CacheInit extends Zend_Controller_Plugin_Abstract { public function __construct() { $frontendOptions = array( 'automatic_serialization' => true, 'lifetime' => 60 ); $backendOptions = array( 'cache_dir' => realpath(APPLICATION_PATH . '/../cache') ); $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions); Zend_Registry::set('cache', $cache); } } |
Than add it as a front controller plugin:
// cache plugin $frontController->registerPlugin(new CacheInit()); |