public function testキャッシュがない場合はキャッシュを生成する() { $appPath = dirname(__FILE__); $cachePath = $appPath . '/var/cache/'; $configPath = $appPath . '/var/config/'; $instance = Gene_Cache_File::getInstance($appPath . '/'); $options = array('frontend' => array('master_files' => $appPath . '/var/config/test.ini'), 'backend' => array('cache_dir' => $cachePath)); $cache = $instance->setOptions($options)->getCache('test'); $cache->clean(Zend_Cache::CLEANING_MODE_ALL); $config = Gene_Config::load($appPath . '/var/config/test.ini', $cache); $this->assertTrue($config instanceof Zend_Config_Ini); $path = pathinfo(str_replace('/', '_', $configPath . 'test'), PATHINFO_FILENAME); $files = array('zend_cache---' . $path, 'zend_cache---internal-metadatas---' . $path); $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($cachePath . 'test')); $actual = array(); foreach ($iterator as $val) { if ($val->isFile()) { $actual[] = $val->getFilename(); } } sort($files); sort($actual); $this->assertEquals($actual, $files); $cache->clean(Zend_Cache::CLEANING_MODE_ALL); }
public function testCacheから読み込んだ設定ファイルからエンジン取得できる() { $appPath = GENE_TEST_ROOT; $cachePath = $appPath . '/var/cache'; $configPath = $appPath . '/var/config/view.ini'; $instance = Gene_Cache_File::getInstance(GENE_TEST_ROOT); $options = array('frontend' => array('master_files' => $configPath), 'backend' => array('cache_dir' => $cachePath)); $cache = $instance->setOptions($options)->getCache('view'); $config = Gene_Config::load($configPath, $cache); $instance = new Gene_View_Adapter($config); $view = $instance->getView(); $this->assertTrue($instance instanceof Gene_View_Adapter); $this->assertTrue($view instanceof Zend_View); }
/** * Get cache object. * * @param mixed $path Path to master files * @param string $name Cache object name * @access public * @return Zend_Cache Cache object */ public function getCacheFileObject($path, $name = 'translates') { $cachePath = $this->_cachePath; if (is_null($cachePath)) { $cachePath = $this->getAppPath(); } $instance = Gene_Cache_File::getInstance($cachePath); $frontend = array('master_files' => $instance->directorySearch($path)); $cache = $instance->setFrontend($frontend)->getCache($name); return $cache; }
/** * Prepare to create cache object * * @access protected * @return Gene_Bootstrap Fluent interface */ protected function _initCache() { $instance = Gene_Cache_File::getInstance($this->_appPath); $frontend = array('master_files' => $instance->directorySearch()); $this->_cache = $instance->setFrontend($frontend)->getCache('config'); return $this; }
public function testCacheオブジェクトに複数のmasterfileを設定できる() { $appPath = dirname(__FILE__); $cachePath = $appPath . '/var/cache/'; $instance = Gene_Cache_File::getInstance(GENE_APP_PATH); $options = array('frontend' => array('master_files' => array($appPath . '/var/config/test.ini', $appPath . '/var/config/test2.ini')), 'backend' => array('cache_dir' => $cachePath)); $actual = $instance->setOptions($options)->getCache('test'); $this->assertTrue($actual instanceof Zend_Cache_Frontend_File); }