2010-05-13 79 views
0

我正在使用Zend Cache進行頁面緩存,但似乎在一段時間後會錯過緩存。有一段時間它是好的,但我明天回來並擊中頁面,它不會從緩存中獲取內容。爲什麼?Zend Cache在一段時間後沒有檢索緩存項目

$frontendOptions = array(
    'content_type_memorization' => true, // This remembers the headers, needed for images 
    'lifetime' => NULL,     // cache lifetime forever 
    'automatic_serialization' => true, 
    'automatic_cleaning_factor' => 0 
); 

$myPageCache = new Zend_Cache_Frontend_Page(array(
    'debug_header' => false, 
    'automatic_cleaning_factor'=>0, 
    'content_type_memorization' => true, 
    'default_options'   => array(
    'cache' => true, 
    'cache_with_get_variables' => true, 
    'cache_with_post_variables' => true, 
    'cache_with_session_variables' => true, 
    'cache_with_cookie_variables' => true 
    ))); 


$backendOptions = array('cache_dir' => '.' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR); 

$cache = Zend_Cache::factory($myPageCache, 
          'File', 
          $frontendOptions, 
          $backendOptions); 

$cacheKey = hash('md5', "cache_" . $cachePath); // cachePath is the key I use for the cache 

if(!$cache->start($cacheKey)) { 
I output html here 
$cache->end(); 
} 

回答

3

確實。我的靜態方法

Zend_Cache::factory($frontend, $back, $frontendOptions, $backendOptions, ...) 

的讀取是,當你通過爲$frontend參數字符串$frontendOptions只能使用。如果您正在傳遞具體實例,則會忽略$frontendOptions

如果您仍想將具體實例$myPageCache傳遞到工廠,那麼您似乎需要將生命期參數(及其他參數)傳遞到創建該實例的調用中。否則,您可以加載單個$frontendOptions陣列並使用:

$cache = Zend_Cache::factory('Page', 'File', $frontendOptions, $backendOptions); 
0

ahh ... opps。

是因爲我的'lifetime'=> NULL,被忽略?

相關問題