【php开源代码栏目提醒】:网学会员,鉴于大家对php开源代码十分关注,论文会员在此为大家搜集整理了“Cache.class.php”一文,供大家参考学习!
<?php
// +----------------------------------------------------------------------
// | ThinkPHP
// +----------------------------------------------------------------------
// | Copyright (c) 2008 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <
Cache.class.php为[网学网-网友上传,谢谢支持]。>
// +----------------------------------------------------------------------
// $Id$
/**
+------------------------------------------------------------------------------
* 缂撳瓨绠$悊绫?
+------------------------------------------------------------------------------
* @category Think
* @package Think
* @subpackage Util
* @author liu21st <
Cache.class.php为[网学网-网友上传,谢谢支持]。>
* @version $Id$
+------------------------------------------------------------------------------
*/
class Cache extends Base
{//绫诲畾涔夊紑濮?
/**
+----------------------------------------------------------
* 鏄惁杩炴帴
+----------------------------------------------------------
* @var string
* @access protected
+----------------------------------------------------------
*/
protected $connected ;
/**
+----------------------------------------------------------
* 鎿嶄綔鍙ユ焺
+----------------------------------------------------------
* @var string
* @access protected
+----------------------------------------------------------
*/
protected $handler ;
/**
+----------------------------------------------------------
* 缂撳瓨瀛樺偍鍓嶇紑
+----------------------------------------------------------
* @var string
* @access protected
+----------------------------------------------------------
*/
protected $prefix='~@';
/**
+----------------------------------------------------------
* 缂撳瓨杩炴帴鍙傛暟
+----------------------------------------------------------
* @var integer
* @access protected
+----------------------------------------------------------
*/
protected $options = array();
/**
+----------------------------------------------------------
* 缂撳瓨绫诲瀷
+----------------------------------------------------------
* @var integer
* @access protected
+----------------------------------------------------------
*/
protected $type ;
/**
+----------------------------------------------------------
* 缂撳瓨杩囨湡鏃堕棿
+----------------------------------------------------------
* @var integer
* @access protected
+----------------------------------------------------------
*/
protected $expire ;
/**
+----------------------------------------------------------
* 杩炴帴缂撳瓨
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param string $type 缂撳瓨绫诲瀷
* @param array $options 閰嶇疆鏁扮粍
+----------------------------------------------------------
* @return object
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function connect($type='',$options=array())
{
if(empty($type)){
$type = C('DATA_CACHE_TYPE');
}
if(Session::is_set('CACHE_'.strtoupper($type))) {
$cacheClass = Session::get('CACHE_'.strtoupper($type));
}else {
$cachePath = dirname(__FILE__).'/Cache/';
$cacheClass = 'Cache'.ucwords(strtolower(trim($type)));
require_cache($cachePath.$cacheClass.'.class.php');
}
if(class_exists($cacheClass)){
$cache = new $cacheClass($options);
}else {
throw_exception(L('_CACHE_TYPE_INVALID_').':'.$type);
}
return $cache;
}
protected function __get($name) {
return $this->get($name);
}
protected function __set($name,$value) {
return $this->set($name,$value);
}
public function setOptions($name,$value) {
$this->options[$name] = $value;
}
public function getOptions($name) {
return $this->options[$name];
}
/**
+----------------------------------------------------------
* 鍙栧緱缂撳瓨绫诲疄渚?
+----------------------------------------------------------
* @static
* @access public
+----------------------------------------------------------
* @return mixed
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
static function getInstance()
{
$param = func_get_args();
return get_instance_of(__CLASS__,'connect',$param);
}
// 璇诲彇缂撳瓨娆℃暟
public function Q($times='') {
static $_times = 0;
if(empty($times)) {
return $_times;
}else{
$_times++;
}
}
// 鍐欏叆缂撳瓨娆℃暟
public function W($times='') {
static $_times = 0;
if(empty($times)) {
return $_times;
}else{
$_times++;
}
}
}//绫诲畾涔夌粨鏉?
?>
上一篇:
c.php
下一篇:
让我掉下眼泪的