【php开源代码栏目提醒】:网学会员在php开源代码频道为大家收集整理了CacheEaccelerator.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$
/**
+------------------------------------------------------------------------------
* Eaccelerator缂撳瓨绫?
+------------------------------------------------------------------------------
* @category Think
* @package Think
* @subpackage Util
* @author liu21st <liu21st@gmail.com>
* @version $Id$
+------------------------------------------------------------------------------
*/
class CacheEaccelerator extends Cache
{
/**
+----------------------------------------------------------
* 鏋舵瀯鍑芥暟
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
*/
public function __construct($options='')
{
$this->type = strtoupper(substr(__CLASS__,6));
}
/**
+----------------------------------------------------------
* 璇诲彇缂撳瓨
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $name 缂撳瓨鍙橀噺鍚?
+----------------------------------------------------------
* @return mixed
+----------------------------------------------------------
*/
public function get($name)
{
$this->Q(1);
return eaccelerator_get($name);
}
/**
+----------------------------------------------------------
* 鍐欏叆缂撳瓨
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $name 缂撳瓨鍙橀噺鍚?
* @param mixed $value 瀛樺偍鏁版嵁
+----------------------------------------------------------
* @return boolen
+----------------------------------------------------------
*/
public function set($name, $value, $ttl = null)
{
$this->W(1);
if(isset($ttl) && is_int($ttl))
$expire = $ttl;
else
$expire = $this->expire;
eaccelerator_lock($name);
return eaccelerator_put ($name, $value, $expire);
}
/**
+----------------------------------------------------------
* 鍒犻櫎缂撳瓨
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $name 缂撳瓨鍙橀噺鍚?
+----------------------------------------------------------
* @return boolen
+----------------------------------------------------------
*/
public function rm($name)
{
return eaccelerator_rm($name);
}
}//绫诲畾涔夌粨鏉?
?>