Esempio n. 1
0
 public function testConfigTemplatesDetectedAsAvailableCaches()
 {
     $manager = new Zend_Cache_Manager();
     $this->assertTrue($manager->hasCache('page'));
 }
Esempio n. 2
0
 /**
  * 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];
 }