當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。