/** * 查询并缓存 * @param object $sql * @param object $lifetime [optional] * @return */ public function queryAndCache($sql, $lifetime = 5) { $cacheData = zcache::get($sql); if (!$cacheData) { $rs = $this->query($sql); $cacheData = $this->got_array($rs); zcache::set($sql, $cacheData, $lifetime); } return $cacheData; }
/** * 调用缓存处理 * @return */ public function saveCache() { if ($this->_cacheThis == true) { $val = ob_get_contents(); $key = $_SERVER['REQUEST_URI']; zcache::set($key, $val, $this->_cacheTime); } }