TA_CACHE_COMPRESS') && function_exists('gzcompress')) {
//鏁版嵁鍘嬬缉
$data = gzcompress($data,3);
}
if(C('DATA_CACHE_CHECK')) {//寮鍚暟鎹牎楠?
$crc = md5($data);
}else {
$crc = '';
}
$expire = !empty($expireTime)? $expireTime : $this->options['expire'];
$map = new HashMap();
$map->put('cachekey',$name);
$map->put('data',$data);
$map->put('datacrc',$crc);
$map->put('expire',($expireTime==-1)?-1: (time()+$expire) );//缂撳瓨鏈夋晥鏈熶负锛?琛ㄧず姘镐箙缂撳瓨
$map->put('datasize',strlen($data));
$result = $this->db->getRow('select `id` from `'.$this->options['table'].'` where `cachekey`=\''.$name.'\' limit 0,1');
if(false !== $result ) {
//鏇存柊璁板綍
$result = $this->db->save($map,$this->options['table'],'`cachekey`=\''.$name.'\'');
}else {
//鏂板璁板綍
$result = $this->db->add($map,$this->options['table']);
}
if($result) {
return true;
}else {
return false;
}
}
/**
+----------------------------------------------------------
* 鍒犻櫎缂撳瓨
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $name 缂撳瓨鍙橀噺鍚?
+----------------------------------------------------------
* @return boolen
+----------------------------------------------------------
*/
public function rm($name)
{
$name = addslashes($name);
return $this->db->_execute('delete from `'.$this->options['table'].'` where `cachekey`=\''.$name.'\'');
}
/**
+----------------------------------------------------------
* 娓呴櫎缂撳瓨
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @return boolen
+----------------------------------------------------------
*/
public function clear()
{
return $this->db->_execute('truncate table `'.$this->options['table'].'`');
}
}//绫诲畾涔夌粨鏉?
?>