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


PHP Memcache::increment方法代码示例

本文整理汇总了PHP中Memcache::increment方法的典型用法代码示例。如果您正苦于以下问题:PHP Memcache::increment方法的具体用法?PHP Memcache::increment怎么用?PHP Memcache::increment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Memcache的用法示例。


在下文中一共展示了Memcache::increment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: increment

 /**
  * Increment cache item with given key
  *
  * @param string $key
  * @return integer|false
  */
 public function increment($key)
 {
     if (empty($key)) {
         throw new InvalidArgumentException("\$key is empty");
     }
     return $this->memcache->increment($key);
 }
开发者ID:Welvin,项目名称:stingle,代码行数:13,代码来源:MemcacheWrapper.class.php

示例2: increment

 public function increment($key, $value)
 {
     try {
         return $this->instance->increment($key, $value);
     } catch (BaseException $e) {
         return null;
     }
 }
开发者ID:justthefish,项目名称:hesper,代码行数:8,代码来源:PeclMemcache.php

示例3: increment

 /**
  * Increment the value of the given key
  *
  * @param string $key
  * @return boolean
  */
 public function increment($key)
 {
     if (!$this->hasMemcache) {
         return false;
     }
     $this->memcache->increment($key);
     return true;
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:14,代码来源:MemcacheService.php

示例4: inc

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

示例5: increment

 /**
  * @inheritdoc
  */
 public function increment($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->increment($hash, $offset);
 }
开发者ID:romeoz,项目名称:rock-cache,代码行数:14,代码来源:Memcache.php

示例6: get_memcache

 /**
  * Get global handle for memcache access
  *
  * @return object Memcache
  */
 public function get_memcache()
 {
     if (!isset($this->memcache)) {
         // no memcache support in PHP
         if (!class_exists('Memcache')) {
             $this->memcache = false;
             return false;
         }
         $this->memcache = new Memcache();
         $this->mc_available = 0;
         // add all configured hosts to pool
         $pconnect = $this->config->get('memcache_pconnect', true);
         foreach ($this->config->get('memcache_hosts', array()) as $host) {
             if (substr($host, 0, 7) != 'unix://') {
                 list($host, $port) = explode(':', $host);
                 if (!$port) {
                     $port = 11211;
                 }
             } else {
                 $port = 0;
             }
             $this->mc_available += intval($this->memcache->addServer($host, $port, $pconnect, 1, 1, 15, false, array($this, 'memcache_failure')));
         }
         // test connection and failover (will result in $this->mc_available == 0 on complete failure)
         $this->memcache->increment('__CONNECTIONTEST__', 1);
         // NOP if key doesn't exist
         if (!$this->mc_available) {
             $this->memcache = false;
         }
     }
     return $this->memcache;
 }
开发者ID:neynah,项目名称:roundcubemail,代码行数:37,代码来源:rcube.php

示例7: increment

 /**
  * Increments the value of an integer cached key
  *
  * @param string $key Identifier for the data
  * @param integer $offset How much to increment
  * @return New incremented value, false otherwise
  * @throws CacheException when you try to increment with compress = true
  */
 public function increment($key, $offset = 1)
 {
     if ($this->settings['compress']) {
         throw new CacheException(__d('cake_dev', 'Method increment() not implemented for compressed cache in %s', __CLASS__));
     }
     return $this->_Memcache->increment($key, $offset);
 }
开发者ID:ronaldsalazar23,项目名称:ComercialChiriguano,代码行数:15,代码来源:MemcacheEngine.php

示例8: cache

function cache($op, $key, $val = '', $expiry = 604800)
{
    static $memcache = false;
    if ($memcache === false) {
        $memcache = new Memcache();
        $memcache->connect('localhost', 11211) or die('Fatal error - could not connect to Memcache');
    }
    $retval = true;
    // Prefix the key to avoid collisions with other apps
    $key = 'twitapps_' . $key;
    switch ($op) {
        case 'set':
            $memcache->set($key, $val, false, $expiry) or die('Fatal error - could not store ' . htmlentities($key) . ' in Memcache');
            break;
        case 'get':
            $retval = $memcache->get($key);
            break;
        case 'inc':
            $retval = $memcache->increment($key);
            break;
        case 'add':
            $retval = $memcache->add($key, $val, false, $expiry);
            break;
    }
    return $retval;
}
开发者ID:ntulip,项目名称:TwitApps,代码行数:26,代码来源:shared.php

示例9: increment

 /**
  * Increments the value of an integer cached key
  *
  * @param string $key
  *        	Identifier for the data
  * @param integer $offset
  *        	How much to increment
  * @param integer $duration
  *        	How long to cache the data, in seconds
  * @return New incremented value, false otherwise
  * @access public
  */
 function increment($key, $offset = 1)
 {
     if ($this->settings['compress']) {
         trigger_error(sprintf(__('Method increment() not implemented for compressed cache in %s', true), get_class($this)), E_USER_ERROR);
     }
     return $this->__Memcache->increment($key, $offset);
 }
开发者ID:arendasistemasintegrados,项目名称:mateusleme,代码行数:19,代码来源:memcache.php

示例10: inc

 function inc($key)
 {
     $key = str_replace('\\', '/', $key);
     if (!$this->memcache->increment($key)) {
         $message = sprintf('Memcache::increment() with key "%s" failed', $key);
         \ManiaLib\Utils\Logger::error($message);
     }
 }
开发者ID:kremsy,项目名称:manialib,代码行数:8,代码来源:Memcache.php

示例11: increment

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

示例12: clearCache

 /**
  * Clears the cache by incrementing the namespace key
  *
  * @return void
  */
 public function clearCache($partition = '')
 {
     if (!$this->connected) {
         return false;
     }
     // Memcache has a built in increment method
     $this->memcache->increment($partition);
 }
开发者ID:CodeBooks,项目名称:php-master-write-cutting-edge-code,代码行数:13,代码来源:Memcache.php

示例13: increment

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

示例14: incrementCachedVal

 protected function incrementCachedVal($cacheKey)
 {
     if (self::$memcache) {
         if ($this->cachePrefix) {
             $cacheKey = $this->cachePrefix . "-" . $cacheKey;
         }
         return self::$memcache->increment($cacheKey);
     }
     return False;
 }
开发者ID:Eygle,项目名称:INeedU,代码行数:10,代码来源:DAO.class.php

示例15: increment

 /**
  * 递增
  * 与原始increment方法区别的是若memcache不存指定KEY时返回false,这个会自动递增
  *
  * @param string $key
  * @param int $offset
  * @param int $lifetime 当递减失则时当作set使用
  */
 public function increment($key, $offset = 1, $lifetime = 60)
 {
     if ($this->_memcache->increment($this->prefix . $key, $offset)) {
         return true;
     } elseif (null === $this->get($key) && $this->set($key, $offset, $lifetime)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:myqee,项目名称:core,代码行数:18,代码来源:memcache.class.php


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