使用Zend Data Cache-PHP API,是否有一种方法可以检索命名空间中的所有键?
从本质上讲,我需要复制你可以用apc_cache_info做的事情,比如
$info = apc_cache_info("user");
$keys = array();
foreach ($info["cache_list"] as $entry) {
$keys[] = $entry["info"];
}
从文件中看不出这是否可能。
谢谢。
class Zend_Cache_Backend_File
{
....
/**
* Return an array of stored tags
*
* @return array array of stored tags (string)
*/
public function getTags()
{
return $this->_get($this->_options['cache_dir'], 'tags', array());
}
/**
* Return an array of stored tags
*
* @return array array of stored tags (string)
*/
public function getTags()
{
return $this->_get($this->_options['cache_dir'], 'tags', array());
}
在我的引导文件中,我初始化缓存
protected function _initCache()
{
$frontendOptions = array(
'lifetime' => 3600*24*5, // cache lifetime of 5 days
'automatic_serialization' => true,
'logging' => false,
'caching' => true
);
$backendOptions = array(
'cache_dir' => './../data/cache/', // Directory where to put the cache files
'hashed_directory_level' => 2
);
// getting a Zend_Cache_Core object
$cache = Zend_Cache::factory(
'Core',
'File',
$frontendOptions,
$backendOptions);
Zend_Registry::set('cache', $cache);
然后在我的控制器中,我可以呼叫
public function indexAction()
{
$cache = Zend_Registry::get('cache');
Zend_Debug::dump($cache->getTags());
Zend_Debug::dump($cache->getIds());
建议您检查Zend代码中使用的特定缓存后端。
后端支持Zend'Cache'Storage'Adapter'FilesystemIterator
Interator:
$cache = $this->serviceLocator->get('yourFilesystemCacheHere');
$iterator = $cache->getIterator();
foreach($iterator as $key){
echo $key;
}