Esempio n. 1
0
 /**
  * Retrieve Zend_Cache_Manager instance
  *
  * @return Zend_Cache_Manager
  */
 public function getCacheManager()
 {
     if (null === $this->_manager) {
         $this->_manager = new Zend_Cache_Manager();
         $options = $this->getOptions();
         if (!App_Filesystem_Folder::exists($options['page']['backend']['options']['cache_dir'])) {
             if (App_Filesystem_Folder::create($options['page']['backend']['options']['cache_dir'])) {
                 $getout = fopen($options['page']['backend']['options']['cache_dir'] . "/index.html", "w") or die("Unable to open file!");
                 fwrite($getout, "Get out\n");
                 fclose($getout);
             } else {
             }
         }
         if (!App_Filesystem_Folder::exists($options['database']['backend']['options']['cache_dir'])) {
             if (App_Filesystem_Folder::create($options['database']['backend']['options']['cache_dir'])) {
                 $getout = fopen($options['database']['backend']['options']['cache_dir'] . "/index.html", "w") or die("Unable to open file!");
                 fwrite($getout, "Get out\n");
                 fclose($getout);
             } else {
             }
         }
         foreach ($options as $key => $value) {
             if ($this->_manager->hasCacheTemplate($key)) {
                 $this->_manager->setTemplateOptions($key, $value);
             } else {
                 $this->_manager->setCacheTemplate($key, $value);
             }
         }
     }
     return $this->_manager;
 }
 /**
  * Retrieve Zend_Cache_Manager instance
  *
  * @return Zend_Cache_Manager
  */
 public function getCacheManager()
 {
     if (null === $this->_manager) {
         $this->_manager = new Zend_Cache_Manager();
         $options = $this->getOptions();
         foreach ($options as $key => $value) {
             if ($this->_manager->hasCacheTemplate($key)) {
                 $this->_manager->setTemplateOptions($key, $value);
             } else {
                 $this->_manager->setCacheTemplate($key, $value);
             }
         }
     }
     return $this->_manager;
 }
 /**
  * Retrieve Zend_Cache_Manager instance
  *
  * @return Zend_Cache_Manager
  */
 public function getCacheManager()
 {
     if (null === $this->_manager) {
         $this->_manager = new Zend_Cache_Manager();
         $options = $this->getOptions();
         foreach ($options as $key => $value) {
             // Logger
             if (isset($value['frontend']['options']['logger'])) {
                 $logger = $value['frontend']['options']['logger'];
                 if (is_array($logger)) {
                     $value['frontend']['options']['logger'] = Zend_Log::factory($logger);
                 }
             }
             // Cache templates
             if ($this->_manager->hasCacheTemplate($key)) {
                 $this->_manager->setTemplateOptions($key, $value);
             } else {
                 $this->_manager->setCacheTemplate($key, $value);
             }
         }
     }
     return $this->_manager;
 }
Esempio n. 4
0
 /**
  * Create cache manager service
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return CacheManager
  * @throws Exception\RuntimeException
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get('Config');
     if (!isset($config['cache_manager'])) {
         throw new Exception\RuntimeException('No cache manager config found.');
     }
     $options = $config['cache_manager'];
     $manager = new CacheManager();
     foreach ($options as $key => $value) {
         if ($manager->hasCacheTemplate($key)) {
             $manager->setTemplateOptions($key, $value);
         } else {
             $manager->setCacheTemplate($key, $value);
         }
     }
     return $manager;
 }
Esempio n. 5
0
 public function testCanOverrideCacheBackendOptionsConfiguration()
 {
     $manager = new Zend_Cache_Manager();
     $manager->setTemplateOptions('page', array('backend' => array('options' => array('public_dir' => './cacheDir'))));
     $config = $manager->getCacheTemplate('page');
     $this->assertEquals('./cacheDir', $config['backend']['options']['public_dir']);
 }
Esempio n. 6
0
 public function testGettingPageCacheAlsoCreatesTagCache()
 {
     $manager = new Zend_Cache_Manager();
     $tagCacheConfig = $manager->getCacheTemplate('tagCache');
     $tagCacheConfig['backend']['options']['cache_dir'] = $this->getTmpDir();
     $manager->setTemplateOptions('pagetag', $tagCacheConfig);
     $tagCache = $manager->getCache('page')->getBackend()->getOption('tag_cache');
     $this->assertTrue($tagCache instanceof Zend_Cache_Core);
 }
Esempio n. 7
0
 /**
  * @group GH-189
  */
 public function testSetsOptionsWithCustomFrontendAndBackendNamingAndAutoload()
 {
     $manager = new Zend_Cache_Manager();
     $manager->setTemplateOptions('page', array('frontend' => array('customFrontendNaming' => true), 'backend' => array('customBackendNaming' => true), 'frontendBackendAutoload' => true));
     $config = $manager->getCacheTemplate('page');
     $this->assertTrue($config['frontend']['customFrontendNaming']);
     $this->assertTrue($config['backend']['customBackendNaming']);
     $this->assertTrue($config['frontendBackendAutoload']);
 }
Esempio n. 8
0
 /**
  * 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);
 }