Files
framework/Think/Cache.php
thinkphp b2b4edaee0 测试
2013-03-13 14:15:52 +08:00

42 lines
1.3 KiB
PHP

<?php
// +----------------------------------------------------------------------
// | ThinkCache
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2012 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace Think;
class Cache {
/**
* 操作句柄
* @var object
* @access protected
*/
static protected $handler = null;
/**
* 连接缓存
* @access public
* @param array $options 配置数组
* @return object
*/
static public function connect($options=[]) {
$type = !empty($options['type'])?$options['type']:'File';
$class = 'Think\\Cache\\Driver\\'.ucwords($type);
if(class_exists($class)) {
self::$handler = new $class($options);
return self::$handler;
}else{
Error::halt('_CACHE_TYPE_INVALID_:'.$type);
}
}
public static function __callStatic($method, $params){
return call_user_func_array(array(self::$handler, $method), $params);
}
}