【php开源代码栏目提醒】:网学会员鉴于大家对php开源代码十分关注,论文会员在此为大家搜集整理了“CacheApc.class.php”一文,供大家参考学习
<?php
// +----------------------------------------------------------------------
// | Think
PHP // +----------------------------------------------------------------------
// | Copyright (c) 2008 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// $Id$
/**
+------------------------------------------------------------------------------
* Apc缂撳瓨绫?
+------------------------------------------------------------------------------
* @category Think
* @package Think
* @subpackage Util
* @author liu21st <liu21st@gmail.com>
* @version $Id$
+------------------------------------------------------------------------------
*/
class CacheApc extends Cache
{//绫诲畾涔夊紑濮?
/**
+----------------------------------------------------------
* 鏋舵瀯鍑芥暟
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
*/
function __construct($options='')
{
if(!function_exists('apc_cache_info')) {
throw_exception(L('绯荤粺涓嶆敮鎸丄pc'));
}
$this->expire = isset($options['expire'])?$options['expire']:C('DATA_CACHE_TIME');
$this->type = strtoupper(substr(__CLASS__,6));
}
/**
+----------------------------------------------------------
* 璇诲彇缂撳瓨
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $name 缂撳瓨鍙橀噺鍚?
+----------------------------------------------------------
* @return mixed
+----------------------------------------------------------
*/
function get($name)
{
$this->Q(1);
return apc_fetch($name);
}
/**
+----------------------------------------------------------
* 鍐欏叆缂撳瓨
*
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $name 缂撳瓨鍙橀噺鍚?
* @param mixed $value 瀛樺偍鏁版嵁
+----------------------------------------------------------
* @return boolen
+----------------------------------------------------------
*/
function set($name, $value, $ttl = null)
{
$this->W(1);
if(isset($ttl) && is_int($ttl))
$expire = $ttl;
else
$expire = $this->expire;
return apc_store($name, $value, $expire);
}
/**
+----------------------------------------------------------
* 鍒犻櫎缂撳瓨
*
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $name 缂撳瓨鍙橀噺鍚?
+----------------------------------------------------------
* @return boolen
+----------------------------------------------------------
*/
function rm($name)
{
return apc_delete($name);
}
/**
+----------------------------------------------------------
* 娓呴櫎缂撳瓨
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @return boolen
+----------------------------------------------------------
*/
function clear()
{
return apc_clear_cache();
}
}//绫诲畾涔夌粨鏉?
?>