예제 #1
0
 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);
     }
 }
예제 #2
0
 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());
 }
예제 #3
0
파일: Apcu.php 프로젝트: levmorozov/mii
 /**
  * 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);
 }
예제 #4
0
파일: ApcAdapter.php 프로젝트: orno/cache
 /**
  * {@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;
 }
예제 #5
0
 /**
  * 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;
     }
 }
예제 #6
0
 /**
  * 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;
 }
예제 #7
0
파일: ApcWrapper.php 프로젝트: saj696/pipe
 /**
  * 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);
 }
예제 #8
0
 public function decrement($key)
 {
     return $this->apcu ? apcu_dec($key) : apc_dec($key);
 }
예제 #9
0
 /**
  * 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);
 }
예제 #10
0
 function cache_Dec($key, $step = 1)
 {
     global $CACHE_STORE_COUNT;
     $CACHE_STORE_COUNT++;
     return apcu_dec($key, $step);
 }
예제 #11
0
파일: APCu.php 프로젝트: pear2/cache_shm
 /**
  * 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;
 }
예제 #12
0
파일: APCu.php 프로젝트: phlak/stash
 /**
  * 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;
 }
예제 #13
0
 public function dec($key, $step = 1)
 {
     $value = apcu_dec($key, $step, $success);
     return $success ? $value : false;
 }
예제 #14
0
파일: Apcu.php 프로젝트: lucidphp/cache
 /**
  * {@inheritdoc}
  */
 protected function decrementValue($key, $value)
 {
     $val = apcu_dec($key, $value, $success);
     return $success ? (int) $val : false;
 }
예제 #15
0
 public function dec(string $key, int $step) : bool
 {
     return apcu_dec($key, $step);
 }
예제 #16
0
 /**
  * {@inheritdoc}
  */
 public function dec($name, $delta = 1)
 {
     if ($this->driver == self::APCU_DRIVER) {
         return apcu_dec($this->prefix . $name, $delta);
     }
     return apc_dec($this->prefix . $name, $delta);
 }
예제 #17
0
 function apc_dec($key, $step = 1, &$success = null)
 {
     return apcu_dec($key, $step, $success);
 }
예제 #18
0
 public function delete($key)
 {
     apcu_dec('__known_apcu_size', strlen($this->load($key)));
     return apcu_delete($key);
 }
예제 #19
0
 /**
  * Decrements the value of an integer cached key
  *
  * @param string $key Identifier for the data
  * @param int $offset How much to subtract
  * @return bool|int New decremented value, false otherwise
  */
 public function decrement($key, $offset = 1)
 {
     $key = $this->_key($key);
     return apcu_dec($key, $offset);
 }
예제 #20
0
 /**
  * {@inheritdoc}
  */
 public function decrement($name, $delta = 1)
 {
     if ($this->driver == self::APCU_DRIVER) {
         return apcu_dec($this->options['prefix'] . $name, $delta);
     }
     return apc_dec($this->options['prefix'] . $name, $delta);
 }
예제 #21
0
파일: Apcu.php 프로젝트: wells5609/wp-app
 public function decr($id, $value = 1, $ttl = Cache::DEFAULT_TTL)
 {
     return apcu_dec($this->prefix . $id, $value);
 }
예제 #22
0
파일: ApcuStore.php 프로젝트: sugiphp/cache
 /**
  * {@inheritdoc}
  */
 public function dec($key, $step = 1)
 {
     return apcu_dec($key, $step);
 }
예제 #23
0
 public function decrement($key, $value)
 {
     return $this->isApcUEnabled ? apcu_dec($key, $value) : apc_dec($key, $value);
 }
예제 #24
0
 public static function rawDecrease($key, $step = 1)
 {
     return function_exists('apcu_dec') ? apcu_dec($key) : apc_dec($key);
 }
예제 #25
0
 public function decrement($key, $value = 1)
 {
     $key = $this->prefix . $key;
     return $this->apcu ? apcu_dec($key, $value) : apc_dec($key, $value);
 }
예제 #26
0
파일: ApcuDriver.php 프로젝트: phpf/cache
 public function decr($id, $val = 1, $group = Cache::DEFAULT_GROUP, $ttl = Cache::DEFAULT_TTL)
 {
     return apcu_dec($this->getPrefix($group) . $id, $val);
 }