Index: library/Zend/Cache/Manager.php =================================================================== --- library/Zend/Cache/Manager.php (revision 22661) +++ library/Zend/Cache/Manager.php (working copy) @@ -57,17 +57,6 @@ * @var array */ protected $_optionTemplates = array( - // Null Cache (Enforce Null/Empty Values) - 'skeleton' => array( - 'frontend' => array( - 'name' => null, - 'options' => array(), - ), - 'backend' => array( - 'name' => null, - 'options' => array(), - ), - ), // Simple Common Default 'default' => array( 'frontend' => array( @@ -79,10 +68,12 @@ 'backend' => array( 'name' => 'File', 'options' => array( - 'cache_dir' => '../cache', + // use system temp dir by default of file backend + // 'cache_dir' => '../cache', ), ), ), + // Static Page HTML Cache 'page' => array( 'frontend' => array( @@ -98,6 +89,7 @@ ), ), ), + // Tag Cache 'pagetag' => array( 'frontend' => array( @@ -110,8 +102,10 @@ 'backend' => array( 'name' => 'File', 'options' => array( - 'cache_dir' => '../cache', - 'cache_file_umask' => 0644 + // use system temp dir by default of file backend + // 'cache_dir' => '../cache', + // use default umask of file backend + // 'cache_file_umask' => 0644 ), ), ), @@ -167,6 +161,7 @@ $this->_optionTemplates[$name]['backend']['options']['tag_cache'] = $this->getCache(self::PAGETAGCACHE); } + $this->_caches[$name] = Zend_Cache::factory( $this->_optionTemplates[$name]['frontend']['name'], $this->_optionTemplates[$name]['backend']['name'], @@ -176,11 +171,28 @@ isset($this->_optionTemplates[$name]['backend']['customBackendNaming']) ? $this->_optionTemplates[$name]['backend']['customBackendNaming'] : false, isset($this->_optionTemplates[$name]['frontendBackendAutoload']) ? $this->_optionTemplates[$name]['frontendBackendAutoload'] : false ); + return $this->_caches[$name]; } } /** + * Fetch all available caches + * + * @return array An array of all available caches with it's names as key + */ + public function getCaches() + { + $caches = $this->_caches; + foreach ($this->_optionTemplates as $name => $tmp) { + if (!isset($caches[$name])) { + $caches[$name] = $this->getCache($name); + } + } + return $caches; + } + + /** * Set a named configuration template from which a cache object can later * be lazy loaded * Index: tests/Zend/Cache/ManagerTest.php =================================================================== --- tests/Zend/Cache/ManagerTest.php (revision 22659) +++ tests/Zend/Cache/ManagerTest.php (working copy) @@ -55,6 +55,18 @@ $this->assertTrue($manager->getCache('cache1') instanceof Zend_Cache_Core); } + /** + * @group ZF-10220 + */ + public function testGetAvialableCaches() + { + $manager = new Zend_Cache_Manager(); + $caches = $manager->getCaches(); + + $this->assertType('array', $caches); + $this->assertArrayHasKey('default', $caches); + } + public function testLazyLoadsDefaultPageCache() { $manager = new Zend_Cache_Manager;