内存缓存 检测加强
This commit is contained in:
@@ -20,10 +20,19 @@ class memory_driver_memcache
|
||||
$connect = @$this->obj->connect($config['server'], $config['port']);
|
||||
}
|
||||
|
||||
$this->enable = $connect ? true : false;
|
||||
$this->enable = $this->checkEnable($connect);
|
||||
}
|
||||
}
|
||||
|
||||
public function checkEnable($connect){
|
||||
if($connect){
|
||||
$this->set('_check_','_check_',10);
|
||||
if($this->get('_check_')=='_check_'){
|
||||
return true;
|
||||
}
|
||||
$this->rm('_check_');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function get($key) {
|
||||
return $this->obj->get($key);
|
||||
}
|
||||
|
||||
@@ -12,9 +12,22 @@ class memory_driver_memcached
|
||||
public function init($config) {
|
||||
if(!empty($config['server'])) {
|
||||
$this->obj = new Memcached();
|
||||
|
||||
$connect = $this->connectd($config['server'], $config['port']);
|
||||
$this->enable = $connect ? true : false;
|
||||
$this->enable=$this->checkEnable($connect);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public function checkEnable($connect){
|
||||
if($connect){
|
||||
$this->set('_check_','_check_',10);
|
||||
if($this->get('_check_')=='_check_'){
|
||||
return true;
|
||||
}
|
||||
$this->rm('_check_');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public function connectd($host , $port){
|
||||
$servers = $this->obj->getServerList();
|
||||
|
||||
@@ -18,7 +18,7 @@ class memory_driver_redis
|
||||
} catch (RedisException $e) {
|
||||
echo $e;
|
||||
}
|
||||
$this->enable = $connect ? true : false;
|
||||
$this->enable = $this->checkEnable($connect);
|
||||
if($this->enable) {
|
||||
if($config['requirepass']) {
|
||||
$this->obj->auth($config['requirepass']);
|
||||
@@ -27,7 +27,16 @@ class memory_driver_redis
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function checkEnable($connect){
|
||||
if($connect){
|
||||
$this->set('_check_','_check_',10);
|
||||
if($this->get('_check_')=='_check_'){
|
||||
return true;
|
||||
}
|
||||
$this->rm('_check_');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function &instance() {
|
||||
static $object;
|
||||
if(empty($object)) {
|
||||
|
||||
Reference in New Issue
Block a user