public function store($key, $value) { if (apcu_store($key, $value)) { apcu_inc('__known_apcu_size', strlen($value)); } return false; }
public static function increment($host) { if (!apcu_exists(self::$prefix . $host)) { apcu_store(self::$prefix . $host, 0, self::$ttl); } apcu_inc(self::$prefix . $host); return apcu_fetch(self::$prefix . $host); }
public function incr($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_inc($key . self::KEY_SUFFIX, $value); } else { return apcu_set($key . self::KEY_SUFFIX, $value); } }
public function increment($key, $amount = 1, $expiration = 0) { $value = apcu_inc($key, $amount, $success); // Call set() if the key doesn't exist. if ($success) { return $value; } else { if ($this->set($key, $amount, $expiration) !== false) { return $amount; } else { return false; } } }
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()); }
/** * Increments 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 increment * @param int step value to increment by * @return integer * @return boolean */ public function increment($id, $step = 1) { return \apcu_inc($id, $step); }
/** * {@inheritdoc} * * @return \Orno\Cache\Adapter\Apc */ public function increment($key, $offset = 1) { if ($this->apcu) { apcu_inc($key, $offset); } else { apc_inc($key, $offset); } return $this; }
/** * Increments 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 increment * @param int step value to increment by * @return integer * @return boolean */ public function increment($id, $step = 1) { if (apcu_exists($id)) { return apcu_inc($id, $step); } else { return FALSE; } }
public function increment($key, $value) { return $this->isApcUEnabled ? apcu_inc($key, $value) : apc_inc($key, $value); }
/** * Use key as a counter and add integet value to it */ public function counter_add($key, $value) { if ($value == 0) { return true; } $storage_key = $this->get_item_key($key); $r = apcu_inc($storage_key, $value); if (!$r) { // it doesnt initialize counter by itself $this->counter_set($key, 0); } return $r; }
function apc_inc($key, $step = 1, &$success = null) { return apcu_inc($key, $step, $success); }
function cache_Inc($key, $step = 1) { global $CACHE_STORE_COUNT; $CACHE_STORE_COUNT++; return apcu_inc($key, $step); }
/** * Increases a value from the shared memory storage. * * Increases 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 increase. * @param int $step Value to increase the key by. * * @return int The new value. */ public function inc($key, $step = 1) { $newValue = apcu_inc($this->persistentId . 'd ' . $key, (int) $step, $success); if (!$success) { throw new SHM\InvalidArgumentException('Unable to increase the value. Are you sure the value is int?', 102); } return $newValue; }
/** * Increase the value of a stored integer * * @param string $key Unique item identifier * @param int $value The ammount by which to increment * * @return mixed Item's new value on success, otherwise false */ public function increment($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_inc($this->prefix($key), $value, $result); } return false; }
public function inc($key, $step = 1) { $value = apcu_inc($key, $step, $success); return $success ? $value : false; }
/** * {@inheritdoc} */ protected function incrementValue($key, $value) { $val = apcu_inc($key, $value, $success); return $success ? (int) $val : false; }
public function inc(string $key, int $step) : bool { return apcu_inc($key, $step); }
/** * Tests that configuring groups for stored keys return the correct values when read/written * Shows that altering the group value is equivalent to deleting all keys under the same * group * * @return void */ public function testGroupsReadWrite() { Cache::config('apc_groups', ['engine' => 'Apc', 'duration' => 0, 'groups' => ['group_a', 'group_b'], 'prefix' => 'test_']); $this->assertTrue(Cache::write('test_groups', 'value', 'apc_groups')); $this->assertEquals('value', Cache::read('test_groups', 'apc_groups')); apcu_inc('test_group_a'); $this->assertFalse(Cache::read('test_groups', 'apc_groups')); $this->assertTrue(Cache::write('test_groups', 'value2', 'apc_groups')); $this->assertEquals('value2', Cache::read('test_groups', 'apc_groups')); apcu_inc('test_group_b'); $this->assertFalse(Cache::read('test_groups', 'apc_groups')); $this->assertTrue(Cache::write('test_groups', 'value3', 'apc_groups')); $this->assertEquals('value3', Cache::read('test_groups', 'apc_groups')); }
/** * {@inheritdoc} */ public function inc($name, $delta = 1) { if ($this->driver == self::APCU_DRIVER) { return apcu_inc($this->prefix . $name, $delta); } return apc_inc($this->prefix . $name, $delta); }
public function incr($id, $value = 1, $ttl = Cache::DEFAULT_TTL) { return apcu_inc($this->prefix . $id, $value); }
/** * Increase a stored number * * @param string $key * @param int $step * @return int | bool */ public function inc($key, $step = 1) { $this->add($key, 0); return apcu_inc($this->getPrefix() . $key, $step); }
/** * {@inheritdoc} * @throws \UnexpectedValueException If existing value is not integer */ protected function incrementInternal($key, $offset = 1, $initial = 0, $expiry = 0) { $realKey = $this->formatKey($key); if (!apcu_exists($realKey) && apcu_store($realKey, $initial, $expiry)) { return $initial; } $success = false; $value = apcu_inc($realKey, $offset, $success); if ($success) { return $value; } $oldValue = apcu_fetch($realKey); if (!is_int($oldValue)) { throw new UnexpectedValueException(sprintf('Method increment() requires existing value to be integer, %s found.', gettype($oldValue))); } return false; }
public function increment($key) { return $this->apcu ? apcu_inc($key) : apc_inc($key); }
/** * Increments the group value to simulate deletion of all keys under a group * old values will remain in storage until they expire. * * @param string $group The group to clear. * @return bool success */ public function clearGroup($group) { apcu_inc($this->_config['prefix'] . $group, 1, $success); return $success; }
/** * Increment the value of an item in the cache. * * @param string $key * @param mixed $value * @return int|bool */ public function increment($key, $value) { return $this->apcu ? apcu_inc($key, $value) : apc_inc($key, $value); }
/** * {@inheritdoc} */ public function increment($name, $delta = 1) { if ($this->driver == self::APCU_DRIVER) { return apcu_inc($this->options['prefix'] . $name, $delta); } return apc_inc($this->options['prefix'] . $name, $delta); }
/** * Internal method to increment an item. * * @param string $normalizedKey * @param int $value * @return int|bool The new value on success, false on failure * @throws Exception\ExceptionInterface */ protected function internalIncrementItem(&$normalizedKey, &$value) { $options = $this->getOptions(); $namespace = $options->getNamespace(); $prefix = $namespace === '' ? '' : $namespace . $options->getNamespaceSeparator(); $internalKey = $prefix . $normalizedKey; $value = (int) $value; $newValue = apcu_inc($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; }
/** * {@inheritdoc} */ public function inc($key, $step = 1) { return apcu_inc($key, $step); }
public function increment($key, $value = 1) { $key = $this->prefix . $key; return $this->apcu ? apcu_inc($key, $value) : apc_inc($key, $value); }
public function incr($id, $val = 1, $group = Cache::DEFAULT_GROUP, $ttl = Cache::DEFAULT_TTL) { return apcu_inc($this->getPrefix($group) . $id, $val); }