예제 #1
0
 public function store($key, $value)
 {
     if (apcu_store($key, $value)) {
         apcu_inc('__known_apcu_size', strlen($value));
     }
     return false;
 }
예제 #2
0
 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);
 }
예제 #3
0
 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);
     }
 }
예제 #4
0
파일: APCu.php 프로젝트: ifixit/matryoshka
 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;
         }
     }
 }
예제 #5
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());
 }
예제 #6
0
파일: Apcu.php 프로젝트: levmorozov/mii
 /**
  * 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);
 }
예제 #7
0
파일: ApcAdapter.php 프로젝트: orno/cache
 /**
  * {@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;
 }
예제 #8
0
 /**
  * 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;
     }
 }
예제 #9
0
 public function increment($key, $value)
 {
     return $this->isApcUEnabled ? apcu_inc($key, $value) : apc_inc($key, $value);
 }
예제 #10
0
 /**
  * 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;
 }
예제 #11
0
 function apc_inc($key, $step = 1, &$success = null)
 {
     return apcu_inc($key, $step, $success);
 }
예제 #12
0
 function cache_Inc($key, $step = 1)
 {
     global $CACHE_STORE_COUNT;
     $CACHE_STORE_COUNT++;
     return apcu_inc($key, $step);
 }
예제 #13
0
파일: APCu.php 프로젝트: pear2/cache_shm
 /**
  * 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;
 }
예제 #14
0
파일: APCu.php 프로젝트: phlak/stash
 /**
  * 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;
 }
예제 #15
0
 public function inc($key, $step = 1)
 {
     $value = apcu_inc($key, $step, $success);
     return $success ? $value : false;
 }
예제 #16
0
파일: Apcu.php 프로젝트: lucidphp/cache
 /**
  * {@inheritdoc}
  */
 protected function incrementValue($key, $value)
 {
     $val = apcu_inc($key, $value, $success);
     return $success ? (int) $val : false;
 }
예제 #17
0
 public function inc(string $key, int $step) : bool
 {
     return apcu_inc($key, $step);
 }
예제 #18
0
 /**
  * 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'));
 }
예제 #19
0
 /**
  * {@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);
 }
예제 #20
0
파일: Apcu.php 프로젝트: wells5609/wp-app
 public function incr($id, $value = 1, $ttl = Cache::DEFAULT_TTL)
 {
     return apcu_inc($this->prefix . $id, $value);
 }
예제 #21
0
 /**
  * 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);
 }
예제 #22
0
파일: Apc.php 프로젝트: gamegos/nosql-apc
 /**
  * {@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;
 }
예제 #23
0
 public function increment($key)
 {
     return $this->apcu ? apcu_inc($key) : apc_inc($key);
 }
예제 #24
0
 /**
  * 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;
 }
예제 #25
0
파일: ApcWrapper.php 프로젝트: saj696/pipe
 /**
  * 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);
 }
예제 #26
0
 /**
  * {@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);
 }
예제 #27
0
 /**
  * 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;
 }
예제 #28
0
파일: ApcuStore.php 프로젝트: sugiphp/cache
 /**
  * {@inheritdoc}
  */
 public function inc($key, $step = 1)
 {
     return apcu_inc($key, $step);
 }
예제 #29
0
 public function increment($key, $value = 1)
 {
     $key = $this->prefix . $key;
     return $this->apcu ? apcu_inc($key, $value) : apc_inc($key, $value);
 }
예제 #30
0
파일: ApcuDriver.php 프로젝트: phpf/cache
 public function incr($id, $val = 1, $group = Cache::DEFAULT_GROUP, $ttl = Cache::DEFAULT_TTL)
 {
     return apcu_inc($this->getPrefix($group) . $id, $val);
 }