当前位置: 首页>>代码示例>>PHP>>正文


PHP Memcache::decrement方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:justthefish,项目名称:hesper,代码行数:8,代码来源:PeclMemcache.php

示例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);
 }
开发者ID:romeoz,项目名称:rock-cache,代码行数:14,代码来源:Memcache.php

示例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);
 }
开发者ID:Welvin,项目名称:stingle,代码行数:13,代码来源:MemcacheWrapper.class.php

示例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);
 }
开发者ID:arendasistemasintegrados,项目名称:mateusleme,代码行数:19,代码来源:memcache.php

示例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);
 }
开发者ID:4Queen,项目名称:php-buildpack,代码行数:15,代码来源:MemcacheEngine.php

示例6: decrement

 public function decrement($key, $value = 1)
 {
     if (!$this->is_open) {
         return false;
     }
     $key = $this->format_key($key);
     return parent::decrement($key, $value);
 }
开发者ID:eywalink,项目名称:worktime,代码行数:8,代码来源:Lib_Memcache.php

示例7: decrement

 public function decrement($key, $value = 1)
 {
     if (!isset($this->memcache)) {
         $this->connect();
     }
     $key = $this->prefix . $key;
     return $this->memcache->decrement($key, $value);
 }
开发者ID:janpoem,项目名称:kephp,代码行数:8,代码来源:Memcache.php

示例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;
     }
 }
开发者ID:myqee,项目名称:core,代码行数:18,代码来源:memcache.class.php

示例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;
 }
开发者ID:dongnan,项目名称:linkcache,代码行数:52,代码来源:Memcache.php

示例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;
 }
开发者ID:nangong92t,项目名称:go_src,代码行数:23,代码来源:Connection.php

示例11: dec

 /**
  * {@inheritdoc}
  */
 public function dec($name, $delta = 1)
 {
     return $this->driver->decrement($name, $delta);
 }
开发者ID:tuneyourserver,项目名称:components,代码行数:7,代码来源:MemcacheDriver.php

示例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);
 }
开发者ID:revolveweb,项目名称:ppi-framework,代码行数:11,代码来源:Memcached.php

示例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);
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:14,代码来源:memcache.php

示例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);
	}
开发者ID:NileshTailor,项目名称:dream,代码行数:11,代码来源:MemcachedEngine.php

示例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;
开发者ID:221V,项目名称:fastchat_kphp,代码行数:31,代码来源:im.php


注:本文中的Memcache::decrement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。