内核更新

This commit is contained in:
2016-07-29 13:48:52 +08:00
parent 75125bb298
commit 9da53fc969
27 changed files with 770 additions and 530 deletions

View File

@@ -11,7 +11,6 @@
namespace think\cache\driver;
use think\Cache;
use think\Exception;
/**
@@ -41,19 +40,29 @@ class Xcache
}
}
/**
* 判断缓存
* @access public
* @param string $name 缓存变量名
* @return bool
*/
public function has($name)
{
$name = $this->options['prefix'] . $name;
return xcache_isset($name);
}
/**
* 读取缓存
* @access public
* @param string $name 缓存变量名
* @param mixed $default 默认值
* @return mixed
*/
public function get($name)
public function get($name, $default = false)
{
$name = $this->options['prefix'] . $name;
if (xcache_isset($name)) {
return xcache_get($name);
}
return false;
return xcache_isset($name) ? xcache_get($name) : $default;
}
/**
@@ -76,6 +85,32 @@ class Xcache
return false;
}
/**
* 自增缓存(针对数值缓存)
* @access public
* @param string $name 缓存变量名
* @param int $step 步长
* @param int $expire 有效时间 0为永久
* @return false|int
*/
public function inc($name, $step = 1, $expire = null)
{
return xcache_inc($name, $step, $expire);
}
/**
* 自减缓存(针对数值缓存)
* @access public
* @param string $name 缓存变量名
* @param int $step 步长
* @param int $expire 有效时间 0为永久
* @return false|int
*/
public function dec($name, $step = 1, $expire = null)
{
return xcache_dec($name, $step, $expire);
}
/**
* 删除缓存
* @access public
@@ -94,6 +129,10 @@ class Xcache
*/
public function clear()
{
return;
if (function_exists('xcache_unset_by_prefix')) {
return xcache_unset_by_prefix($this->options['prefix']);
} else {
return false;
}
}
}