public function testGettingPageCacheAlsoCreatesTagCache() { $manager = new Zend_Cache_Manager(); $tagCacheConfig = $manager->getCacheTemplate('tagCache'); $tagCacheConfig['backend']['options']['cache_dir'] = $this->getTmpDir(); $manager->setCacheTemplate('tagCache', $tagCacheConfig); $tagCache = $manager->getCache('page')->getBackend()->getOption('tag_cache'); $this->assertTrue($tagCache instanceof Zend_Cache_Core); }
/** * Get a cache type from the cache manager * * Get a cache type via the Cache Manager instance or instantiate the object if not * exists. Attempts to load from bootstrap if available. * * @param string * @return Zend_Cache_Core * @throws InvalidArgumentException when incorrect type is provided */ public static function getCache($type) { if (is_string($type) && !array_key_exists($type, self::$_managedCaches)) { $front = Zend_Controller_Front::getInstance(); if ($front->getParam('bootstrap') && $front->getParam('bootstrap')->getResource('CacheManager')) { $manager = $front->getParam('bootstrap')->getResource('CacheManager'); } else { $manager = new Zend_Cache_Manager(); } if (!$manager->hasCache($type)) { throw new InvalidArgumentException('Cache of type ' . $type . ' does not exist!'); } self::$_managedCaches[$type] = $manager->getCache($type); } return self::$_managedCaches[$type]; }
/** * get customized cache object * * @param string $templateName * @param array $customOptions * @return Zend_Cache_Core */ public function getCustomCache($templateName, array $customOptions) { $this->_cacheManager->setTemplateOptions($templateName, $customOptions); return $this->_cacheManager->getCache($templateName); }