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); } }
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()); }
/** * 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); }
/** * {@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; }
/** * 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; } }
/** * 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; }
/** * 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); }
public function decrement($key) { return $this->apcu ? apcu_dec($key) : apc_dec($key); }
/** * 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); }
function cache_Dec($key, $step = 1) { global $CACHE_STORE_COUNT; $CACHE_STORE_COUNT++; return apcu_dec($key, $step); }
/** * 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; }
/** * 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; }
public function dec($key, $step = 1) { $value = apcu_dec($key, $step, $success); return $success ? $value : false; }
/** * {@inheritdoc} */ protected function decrementValue($key, $value) { $val = apcu_dec($key, $value, $success); return $success ? (int) $val : false; }
public function dec(string $key, int $step) : bool { return apcu_dec($key, $step); }
/** * {@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); }
function apc_dec($key, $step = 1, &$success = null) { return apcu_dec($key, $step, $success); }
public function delete($key) { apcu_dec('__known_apcu_size', strlen($this->load($key))); return apcu_delete($key); }
/** * 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); }
/** * {@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); }
public function decr($id, $value = 1, $ttl = Cache::DEFAULT_TTL) { return apcu_dec($this->prefix . $id, $value); }
/** * {@inheritdoc} */ public function dec($key, $step = 1) { return apcu_dec($key, $step); }
public function decrement($key, $value) { return $this->isApcUEnabled ? apcu_dec($key, $value) : apc_dec($key, $value); }
public static function rawDecrease($key, $step = 1) { return function_exists('apcu_dec') ? apcu_dec($key) : apc_dec($key); }
public function decrement($key, $value = 1) { $key = $this->prefix . $key; return $this->apcu ? apcu_dec($key, $value) : apc_dec($key, $value); }
public function decr($id, $val = 1, $group = Cache::DEFAULT_GROUP, $ttl = Cache::DEFAULT_TTL) { return apcu_dec($this->getPrefix($group) . $id, $val); }