本文整理汇总了PHP中Memcache::decrement方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcache::decrement方法的具体用法?PHP Memcache::decrement怎么用?PHP Memcache::decrement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Memcache
的用法示例。
在下文中一共展示了Memcache::decrement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: decrement
public function decrement($key, $value)
{
try {
return $this->instance->decrement($key, $value);
} catch (BaseException $e) {
return null;
}
}
示例2: decrement
/**
* @inheritdoc
*/
public function decrement($key, $offset = 1, $expire = 0, $create = true)
{
$hash = $this->prepareKey($key);
if ($this->exists($key) === false) {
if ($create === false) {
return false;
}
$this->storage->add($hash, 0, MEMCACHE_COMPRESSED, $expire);
}
return $this->storage->decrement($hash, $offset);
}
示例3: decrement
/**
* Decrement cache item with given key
*
* @param string $key
* @return integer|false
*/
public function decrement($key)
{
if (empty($key)) {
throw new InvalidArgumentException("\$key is empty");
}
return $this->memcache->decrement($key);
}
示例4: decrement
/**
* Decrements the value of an integer cached key
*
* @param string $key
* Identifier for the data
* @param integer $offset
* How much to substract
* @param integer $duration
* How long to cache the data, in seconds
* @return New decremented value, false otherwise
* @access public
*/
function decrement($key, $offset = 1)
{
if ($this->settings['compress']) {
trigger_error(sprintf(__('Method decrement() not implemented for compressed cache in %s', true), get_class($this)), E_USER_ERROR);
}
return $this->__Memcache->decrement($key, $offset);
}
示例5: decrement
/**
* Decrements the value of an integer cached key
*
* @param string $key Identifier for the data
* @param integer $offset How much to subtract
* @return New decremented value, false otherwise
* @throws CacheException when you try to decrement with compress = true
*/
public function decrement($key, $offset = 1)
{
if ($this->settings['compress']) {
throw new CacheException(__d('cake_dev', 'Method %s not implemented for compressed cache in %s', 'decrement()', __CLASS__));
}
return $this->_Memcache->decrement($key, $offset);
}
示例6: decrement
public function decrement($key, $value = 1)
{
if (!$this->is_open) {
return false;
}
$key = $this->format_key($key);
return parent::decrement($key, $value);
}
示例7: decrement
public function decrement($key, $value = 1)
{
if (!isset($this->memcache)) {
$this->connect();
}
$key = $this->prefix . $key;
return $this->memcache->decrement($key, $value);
}
示例8: decrement
/**
* 递减
* 与原始decrement方法区别的是若memcache不存指定KEY时返回false,这个会自动递减
*
* @param string $key
* @param int $offset
* @param int $lifetime 当递减失则时当作set使用
*/
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;
}
}
示例9: decr
/**
* 递减
* @param string $key 键名
* @param int $step 递减步长
* @return int|false 递减后的值,失败返回false
*/
public function decr($key, $step = 1)
{
if (!is_int($step)) {
return false;
}
try {
$value = $this->handler->get($key);
if ($value === false) {
if ($this->handler->set($key, $value = -$step, 0)) {
return $value;
}
} else {
//memcache会将数字存储为字符串
if (!is_numeric($value)) {
return false;
}
$timeValue = self::getValue($this->handler->get(self::timeKey($key)));
//未设置过期时间或未过期
if ($timeValue === false || isset($timeValue['expire_time']) && $timeValue['expire_time'] > time()) {
//memcache 新的元素的值不会小于0
if ($value < 0 || $step > 0 && $value < $step) {
if ($this->handler->set($key, $value -= $step, 0)) {
return $value;
}
} else {
if ($step > 0) {
$ret = $this->handler->decrement($key, $step);
return $ret;
} else {
return $this->handler->increment($key, -$step);
}
}
}
//已过期,重新设置
if ($this->handler->set($key, $value = $step, 0)) {
return $value;
}
}
return false;
} catch (Exception $ex) {
self::exception($ex);
//连接状态置为false
$this->isConnected = false;
}
return false;
}
示例10: decrease
/**
*
* @param string $key
* @param int $value
* @return number
* @todo 多备份实例上无原子操作
*/
public function decrease($key, $value = 1)
{
if ($this->backupInstance) {
$backupReturn = $this->backupInstance->decrease($key, $value);
}
$key = $this->makeRealKey($key);
$return = parent::decrement($key, $value);
if ($return === false) {
$newValue = parent::get($key);
if (false !== $newValue) {
$backupValue['data'] = $newValue;
parent::set($this->getBackupKey($key), $backupValue, MEMCACHE_COMPRESSED, 0);
}
}
return $return;
}
示例11: dec
/**
* {@inheritdoc}
*/
public function dec($name, $delta = 1)
{
return $this->driver->decrement($name, $delta);
}
示例12: decrement
/**
* Decrement a cache value
*
* @param string $p_sKey The Key
* @param numeric $p_mDecrement The Decremental Value
* @return numeric
*/
function decrement($p_sKey, $p_mDecrement)
{
return $this->_handler->decrement($p_sKey, $p_mDecrement);
}
示例13: decrement
/**
* Decrements a given value by the step value supplied.
* Useful for shared counters and other persistent integer based
* tracking.
*
* @param string id of cache entry to decrement
* @param int step value to decrement by
* @return integer
* @return boolean
*/
public function decrement($id, $step = 1)
{
return $this->_memcache->decrement($id, $step);
}
示例14: decrement
/**
* Decrements the value of an integer cached key
*
* @param string $key Identifier for the data
* @param int $offset How much to subtract
* @return New decremented value, false otherwise
* @throws CacheException when you try to decrement with compress = true
*/
public function decrement($key, $offset = 1) {
return $this->_Memcached->decrement($key, $offset);
}
示例15: intval
ajax_only();
$peer = intval($_POST['peer']);
$new = get_new_counts($uid, true);
$new_peer = $new['peers'][$peer];
if($new_peer > 0){
foreach($new['ids'][$peer] as $id){
$msg = $im->get("message{$uid}_{$id}#4");
$msg = explode("\t", $msg);
$msg_data = explode(',', $msg[0]);
$im->decrement("flags{$uid}_{$id}", 1);
$im->decrement("flags{$peer}_{$msg_data[3]}", 1);
}
$im->set("history_action{$peer}#51", "{$uid},1");
$queue = new Memcache;
$queue->connect('127.0.0.1', QUE_PORT);
$queue->add("queue(notify{$uid})", json_encode(array('type' => 'msg_count', 'cnt' => $new_msg['all'])));
$dialog_num = $new['unicue']-1;
}else $dialog_num = $new['unicue'];
echo json_encode(array('dialog_num' => $dialog_num));
exit;
break;