内核更新

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;
class Memcache
@@ -56,15 +55,29 @@ class Memcache
}
}
/**
* 判断缓存
* @access public
* @param string $name 缓存变量名
* @return bool
*/
public function has($name)
{
$name = $this->options['prefix'] . $name;
return $this->handler->get($name) ? true : false;
}
/**
* 读取缓存
* @access public
* @param string $name 缓存变量名
* @param mixed $default 默认值
* @return mixed
*/
public function get($name)
public function get($name, $default = false)
{
return $this->handler->get($this->options['prefix'] . $name);
$result = $this->handler->get($this->options['prefix'] . $name);
return false !== $result ? $result : $default;
}
/**
@@ -87,6 +100,32 @@ class Memcache
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 $this->handler->increment($name, $step);
}
/**
* 自减缓存(针对数值缓存)
* @access public
* @param string $name 缓存变量名
* @param int $step 步长
* @param int $expire 有效时间 0为永久
* @return false|int
*/
public function dec($name, $step = 1, $expire = null)
{
return $this->handler->decrement($name, $step);
}
/**
* 删除缓存
* @param string $name 缓存变量名