首页 > 技术文章 > zend cache使用

kobigood 2017-03-24 17:45 原文

require_once 'Zend/Cache.php';//引用文件
$frontendOptions = array(
'lifeTime' => 60, // cache lifetime
'automatic_serialization' => true
);
$backendOptions = array(
'cache_dir' => PUBLIC_PATH.'/tmp/' // Directory where to put the cache files
);
// 取得一个Zend_Cache_Core 对象
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);

if(!$result = $cache->load('myresult')) {
$departmentResult = $this->essDeptInfo->getAllDept($this->db);
$cache->save($departmentResult, 'myresult');//利用zend_cache对象缓存查询出来的结果
}

推荐阅读