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


PHP apcu_dec函数代码示例

本文整理汇总了PHP中apcu_dec函数的典型用法代码示例。如果您正苦于以下问题:PHP apcu_dec函数的具体用法?PHP apcu_dec怎么用?PHP apcu_dec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: decr

 public function decr($key, $value = 1)
 {
     /**
      * @todo When we only support php 7 or higher remove this hack
      *
      * https://github.com/krakjoe/apcu/issues/166
      */
     if (apcu_exists($key . self::KEY_SUFFIX)) {
         return apcu_dec($key . self::KEY_SUFFIX, $value);
     } else {
         return apcu_set($key . self::KEY_SUFFIX, -$value);
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:13,代码来源:APCUBagOStuff.php

示例2: testApcu

 public function testApcu()
 {
     $key = __CLASS__;
     apcu_delete($key);
     $this->assertFalse(apcu_exists($key));
     $this->assertTrue(apcu_add($key, 123));
     $this->assertTrue(apcu_exists($key));
     $this->assertSame(array($key => -1), apcu_add(array($key => 123)));
     $this->assertSame(123, apcu_fetch($key));
     $this->assertTrue(apcu_store($key, 124));
     $this->assertSame(124, apcu_fetch($key));
     $this->assertSame(125, apcu_inc($key));
     $this->assertSame(124, apcu_dec($key));
     $this->assertTrue(apcu_cas($key, 124, 123));
     $this->assertFalse(apcu_cas($key, 124, 123));
     $this->assertTrue(apcu_delete($key));
     $this->assertFalse(apcu_delete($key));
     $this->assertArrayHasKey('cache_list', apcu_cache_info());
 }
开发者ID:derrabus,项目名称:polyfill,代码行数:19,代码来源:ApcuTest.php

示例3: 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 \apcu_dec($id, $step);
 }
开发者ID:levmorozov,项目名称:mii,代码行数:14,代码来源:Apcu.php

示例4: decrement

 /**
  * {@inheritdoc}
  *
  * @return \Orno\Cache\Adapter\Apc
  */
 public function decrement($key, $offset = 1)
 {
     if ($this->apcu) {
         apcu_dec($key, $offset);
     } else {
         apc_dec($key, $offset);
     }
     return $this;
 }
开发者ID:orno,项目名称:cache,代码行数:14,代码来源:ApcAdapter.php

示例5: 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)
 {
     if (apcu_exists($id)) {
         return apcu_dec($id, $step);
     } else {
         return FALSE;
     }
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:18,代码来源:Apcu.php

示例6: internalDecrementItem

 /**
  * Internal method to decrement an item.
  *
  * @param  string $normalizedKey
  * @param  int    $value
  * @return int|bool The new value on success, false on failure
  * @throws Exception\ExceptionInterface
  */
 protected function internalDecrementItem(&$normalizedKey, &$value)
 {
     $options = $this->getOptions();
     $namespace = $options->getNamespace();
     $prefix = $namespace === '' ? '' : $namespace . $options->getNamespaceSeparator();
     $internalKey = $prefix . $normalizedKey;
     $value = (int) $value;
     $newValue = apcu_dec($internalKey, $value);
     // initial value
     if ($newValue === false) {
         $ttl = $options->getTtl();
         $newValue = -$value;
         if (!apcu_add($internalKey, $newValue, $ttl)) {
             throw new Exception\RuntimeException("apcu_add('{$internalKey}', {$newValue}, {$ttl}) failed");
         }
     }
     return $newValue;
 }
开发者ID:stephenmoore56,项目名称:mooredatabase-laravel,代码行数:26,代码来源:Apcu.php

示例7: decrement

 /**
  * Decrement the value of an item in the cache.
  *
  * @param  string $key
  * @param  mixed $value
  * @return int|bool
  */
 public function decrement($key, $value)
 {
     return $this->apcu ? apcu_dec($key, $value) : apc_dec($key, $value);
 }
开发者ID:saj696,项目名称:pipe,代码行数:11,代码来源:ApcWrapper.php

示例8: decrement

 public function decrement($key)
 {
     return $this->apcu ? apcu_dec($key) : apc_dec($key);
 }
开发者ID:vanclei,项目名称:cachephp,代码行数:4,代码来源:APCStore.php

示例9: dec

 /**
  * Decrease a stored number
  *
  * @param string $key
  * @param int $step
  * @return int | bool
  */
 public function dec($key, $step = 1)
 {
     return apcu_dec($this->getPrefix() . $key, $step);
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:11,代码来源:APCu.php

示例10: cache_Dec

 function cache_Dec($key, $step = 1)
 {
     global $CACHE_STORE_COUNT;
     $CACHE_STORE_COUNT++;
     return apcu_dec($key, $step);
 }
开发者ID:LastResortGames,项目名称:ludumdare,代码行数:6,代码来源:cache.php

示例11: dec

 /**
  * Decreases a value from the shared memory storage.
  *
  * Decreases a value from the shared memory storage. Unlike a plain
  * set($key, get($key)-$step) combination, this function also implicitly
  * performs locking.
  *
  * @param string $key  Name of key to decrease.
  * @param int    $step Value to decrease the key by.
  *
  * @return int The new value.
  */
 public function dec($key, $step = 1)
 {
     $newValue = apcu_dec($this->persistentId . 'd ' . $key, (int) $step, $success);
     if (!$success) {
         throw new SHM\InvalidArgumentException('Unable to decrease the value. Are you sure the value is int?', 103);
     }
     return $newValue;
 }
开发者ID:pear2,项目名称:cache_shm,代码行数:20,代码来源:APCu.php

示例12: decrement

 /**
  * Decrease the value of a stored integer
  *
  * @param  string $key   Unique item identifier
  * @param  int    $value The ammount by which to decrement
  *
  * @return mixed         Item's new value on success, otherwise false
  */
 public function decrement($key, $value = 1)
 {
     // Check for key existance first as a temporary workaround
     // for this bug: https://github.com/krakjoe/apcu/issues/183
     if (apcu_exists($this->prefix($key))) {
         return apcu_dec($this->prefix($key), $value);
     }
     return false;
 }
开发者ID:phlak,项目名称:stash,代码行数:17,代码来源:APCu.php

示例13: dec

 public function dec($key, $step = 1)
 {
     $value = apcu_dec($key, $step, $success);
     return $success ? $value : false;
 }
开发者ID:xiaoniainiu,项目名称:php-yaf-yk,代码行数:5,代码来源:cache.php

示例14: decrementValue

 /**
  * {@inheritdoc}
  */
 protected function decrementValue($key, $value)
 {
     $val = apcu_dec($key, $value, $success);
     return $success ? (int) $val : false;
 }
开发者ID:lucidphp,项目名称:cache,代码行数:8,代码来源:Apcu.php

示例15: dec

 public function dec(string $key, int $step) : bool
 {
     return apcu_dec($key, $step);
 }
开发者ID:knowsee,项目名称:uoke_framework,代码行数:4,代码来源:apcu.class.php


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