Zend缓存后端静态移除/清理


Zend Cache Backend Static Remove/Clean

我正在尝试使用Zend cache实现一个缓存。我使用以下代码来初始化缓存。

$tagCache = Zend_Cache::factory('Core',
                                'File',
                                 array('automatic_serialization' => true),
                                 array('cache_dir' => $cfg['instdir']. 'Cache_dir'));
$cache = Zend_Cache::factory('Capture',
                             'Static',
                              array(),
                              array('index_filename' => 'index',
                                    'public_dir'     => $cfg['instdir'] . 'Cached',
                                    'tag_cache'      => $tagCache));

我使用以下代码开始缓存:

$id = bin2hex($_SERVER["REQUEST_URI"]);
$cache->start($id, array());

缓存文件已生成,但我无法使用remove()方法删除它们(缓存不刷新):

$cache->remove($id); // id generated like above from the REQUEST_URI of the page I want to refresh

我做错了什么?谢谢

$cache->remove()是后端remove()方法的代理。在这种情况下,您使用的是Static后端,因此我们会查看其中的情况。

我对该方法的理解使我相信remove$id参数必须是一个文件名,因此:

$cache->remove('index'); 

将起作用。

不过,更常见的清除缓存的方法是使用clean()方法。请参阅手册。