递减 与原始decrement方法区别的是若memcache不存指定KEY时返回false,这个会自动递减
null Driver_Cache_Driver_Memcache::decrement( string $key [, int $offset = integer 1 , int $lifetime = integer 60 ] )
参数列表
参数 类型 描述 默认值 $key
string
$key $offset
int
$offset integer 1 $lifetime
int
当递减失则时当作set使用 integer 60
public function decrement($key, $offset = 1, $lifetime = 60)
{
if ($this->_memcache->decrement($this->prefix . $key, $offset))
{
return true;
}
elseif ($this->get($key) === null && $this->set($key, $offset, $lifetime))
{
return true;
}
else
{
return false;
}
}