public function init() { $bootstrap = $this->getBootstrap(); $bootstrap->bootstrap('Config'); $config = $bootstrap->getResource('Config'); $cacheConfig = $config->cache; if ($cacheConfig) { $this->setOptions($cacheConfig->toArray()); } return parent::init(); }
protected function _initCache() { $this->bootstrap('db'); $options = Zend_Json::decode(Tri_Config::get('cachemanager')); $resource = new Zend_Application_Resource_Cachemanager($options); $cache = $resource->init()->getCache('default'); // Zend_Db_Table::setDefaultMetadataCache($cache); // Zend_Date::setOptions(array('cache' => $cache)); // Zend_Translate::setCache($cache); // Zend_Locale::setCache($cache); Zend_Registry::set('cache', $cache); }
/** * @group ZF-9737 */ public function testCustomFrontendBackendNaming() { $options = array('zf9737' => array('frontend' => array('name' => 'custom-naming', 'customFrontendNaming' => false), 'backend' => array('name' => 'Zend_Cache_Backend_Custom_Naming', 'customBackendNaming' => true), 'frontendBackendAutoload' => true)); $resource = new Zend_Application_Resource_Cachemanager($options); $manager = $resource->init(); $cache = $manager->getCache('zf9737'); $this->assertTrue($cache->getBackend() instanceof Zend_Cache_Backend_Custom_Naming); $this->assertTrue($cache instanceof Zend_Cache_Frontend_CustomNaming); }
/** * @group GH-103 */ public function testLoggerFactory() { $options = array('page' => array('frontend' => array('options' => array('logging' => true, 'logger' => array(new Zend_Log_Writer_Mock()))))); $resource = new Zend_Application_Resource_Cachemanager($options); $resource->setBootstrap($this->bootstrap); $resource->init(); $page = $resource->getCacheManager()->getCache('page'); $page->getBackend()->clean(Zend_Cache::CLEANING_MODE_OLD); $event = current($options['page']['frontend']['options']['logger'][0]->events); $this->assertTrue(is_array($event)); $this->assertTrue(array_key_exists('message', $event)); $this->assertContains('Zend_Cache_Backend_Static', $event['message']); }
public function testEmptyBackendOptionsShouldNotResultInError() { $options = array('foo' => array('frontend' => array('name' => 'Core', 'options' => array('lifetime' => 7200)), 'backend' => array('name' => 'black.hole'))); $resource = new Zend_Application_Resource_Cachemanager($options); $manager = $resource->init(); $cache = $manager->getCache('foo'); $this->assertTrue($cache instanceof Zend_Cache_Core); }
public function init() { $this->_manager = parent::init(); $this->_saveInRegistry(); return $this->_manager; }
/** * @group ZF-9738 */ public function testZendServer() { if (!function_exists('zend_disk_cache_store')) { $this->markTestSkipped('ZendServer is required for this test'); } $options = array('foo' => array('frontend' => array('name' => 'Core', 'options' => array('lifetime' => 7200)), 'backend' => array('name' => 'ZendServer_Disk'))); $resource = new Zend_Application_Resource_Cachemanager($options); $manager = $resource->init(); $cache = $manager->getCache('foo')->getBackend(); $this->assertTrue($cache instanceof Zend_Cache_Backend_ZendServer_Disk); }