Пример #1
0
 public function store($key, $value)
 {
     if (xcache_set($key, $value)) {
         xcache_inc('__known_xcache_size', strlen($value));
     }
     return false;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 protected function incrementValue($key, $value)
 {
     if (is_int($inc = xcache_inc($key, (int) $value))) {
         return $inc;
     }
     return false;
 }
Пример #3
0
 public function add($key, $value = 1, $ttl = 600)
 {
     $result = 0;
     if (is_numeric($value)) {
         $result = $value > 0 ? xcache_inc($key, $value, $ttl) : xcache_dec($key, abs($value), $ttl);
     }
     return $result;
 }
Пример #4
0
 public function modifyInteger($key, $offset, &$success = null)
 {
     $success = false;
     if ($offset > 0) {
         $newValue = xcache_inc($key, $offset);
     } else {
         $newValue = xcache_dec($key, abs($offset));
     }
     if (is_int($newValue)) {
         $success = true;
     }
     return $newValue;
 }
Пример #5
0
 /**
  * Increment the value of an item in the cache.
  *
  * @param  string  $key
  * @param  mixed   $value
  * @return void
  */
 public function increment($key, $value = 1)
 {
     return xcache_inc($this->prefix . $key, $value);
 }
Пример #6
0
 /**
  * 
  * Increments a cache entry value by the specified amount.  If the entry
  * does not exist, creates it at zero, then increments it.
  * 
  * @param string $key The entry ID.
  * 
  * @param string $amt The amount to increment by (default +1).  Using
  * negative values is effectively a decrement.
  * 
  * @return int The new value of the cache entry.
  * 
  */
 public function increment($key, $amt = 1)
 {
     if (!$this->_active) {
         return;
     }
     // modify the key to add the prefix
     $key = $this->entry($key);
     // make sure we have a key to increment
     $this->add($key, 0, null, $this->_life);
     // let xcache do the increment and retain its value
     $val = xcache_inc($key, $amt, $this->_life);
     // done
     return $val;
 }
Пример #7
0
 /**
  * @see Temporary_cache_driver::inc()
  */
 public function inc($id, $realm = COT_DEFAULT_REALM, $value = 1)
 {
     return xcache_inc($realm . '/' . $id, $value);
 }
Пример #8
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;
     $ttl = $options->getTtl();
     $value = (int) $value;
     return xcache_inc($internalKey, $value, $ttl);
 }
Пример #9
0
 public function incr($key, $value = 1)
 {
     return xcache_inc($key, $value);
 }
Пример #10
0
 function increment($key, $by = 1)
 {
     $formatted = \Cachet\Helper::formatKey([$this->prefix, 'counter', $key]);
     $value = xcache_inc($formatted, $by, $this->counterTTL);
     return $value;
 }
Пример #11
0
 /**
  * Increase a stored number
  *
  * @param string $key
  * @param int $step
  * @return int | bool
  */
 public function inc($key, $step = 1)
 {
     return xcache_inc($this->getPrefix() . $key, $step);
 }
Пример #12
0
 /**
  * @param string $key
  * @return array|int
  */
 private function _flush_pool($key = null)
 {
     if (!$this->_get_counter_status()) {
         return [];
     }
     if (empty($this->_pool)) {
         return [];
     }
     if ($key === null) {
         $result = [];
         foreach ($this->_pool as $_key => $_val) {
             $result[$_key] = xcache_inc($_key, $_val);
         }
         $this->_pool = [];
         return $result;
     }
     $_count = 0;
     $key = $this->_hash_key($key);
     if (isset($this->_pool[$key])) {
         $_count = $this->_pool[$key];
         xcache_inc($key, $_count);
         unset($this->_pool[$key]);
     }
     return $_count;
 }
Пример #13
0
 /**
  * {@inheritdoc}
  */
 public function inc($name, $delta = 1)
 {
     return xcache_inc($this->prefix . $name, $delta);
 }
Пример #14
0
 /**
  * Emulates `Memcache::increment`.
  */
 public function increment($key, $value = 1)
 {
     return xcache_inc(self::$key_prefix . $key, $value);
 }
Пример #15
0
 /**
  * Increment the value of an item in the cache.
  *
  * @param  string  $key
  * @param  mixed   $value
  * @return int
  */
 public function increment($key, $value = 1)
 {
     return xcache_inc($this->getPrefixWithLocale() . $key, $value);
 }
Пример #16
0
 /**
  * Increase the value of a key by $amount.
  * 
  * If the key does not exist, this method assumes that the current value is zero.
  * This method returns the new value.
  * 
  * @param string $key
  * @param int $amount
  * @return int
  */
 public function incr($key, $amount)
 {
     return xcache_inc($key, $amount);
 }
Пример #17
0
 /**
  * Increments the value of an integer cached key
  * If the cache key is not an integer it will be treated as 0
  *
  * @param string $key Identifier for the data
  * @param integer $offset How much to increment
  * @return New incremented value, false otherwise
  */
 public function increment($key, $offset = 1)
 {
     return xcache_inc($key, $offset);
 }
Пример #18
0
 {
     // Revision 621
     $cnt = xcache_count(XC_TYPE_VAR);
     for ($i = 0; $i < $cnt; $i++) {
         xcache_clear_cache(XC_TYPE_VAR, $i);
     }
     return true;
 }
 private static function xcache_delete($name)
 {
     $name = self::getMemoryName($name);
     return xcache_unset($name);
Пример #19
0
 public function inc($key, $step = 1)
 {
     $this->type = $type;
     return xcache_inc($this->_key($key), $step);
 }
Пример #20
0
 /**
  * Increases the value in the variable store
  * @param string $key The key of the variable
  * @param integer $value The value to increase with
  * @param integer $timeToLive Set to a number of seconds to make the variable expire in that amount of time
  * @return mixed The new value of the variable
  */
 public function increase($key, $value = null, $timeToLive = null)
 {
     return xcache_inc($key, $value, $timeToLive);
 }
Пример #21
0
 /**
  * Performs an atomic increment operation on specified numeric cache item.
  *
  * Note that, as per the XCache specification:
  * If the item's value is not numeric, it is treated as if the value were 0.
  *
  * @param string $key Key of numeric cache item to increment
  * @param integer $offset Offset to increment - defaults to 1.
  * @return mixed Item's new value on successful increment, false otherwise
  */
 public function increment($key, $offset = 1)
 {
     return function ($self, $params, $chain) use($offset) {
         extract($params);
         return xcache_inc($key, $offset);
     };
 }
Пример #22
0
 public function inc($key, $step = 1)
 {
     return xcache_inc($key, $step);
 }
Пример #23
0
 /**
  * Performs an atomic increment operation on specified numeric cache item.
  *
  * Note that, as per the XCache specification:
  * If the item's value is not numeric, it is treated as if the value were 0.
  *
  * @param string $key Key of numeric cache item to increment.
  * @param integer $offset Offset to increment - defaults to `1`.
  * @return integer|boolean The item's new value on successful increment, else `false`.
  */
 public function increment($key, $offset = 1)
 {
     return xcache_inc($this->_config['scope'] ? "{$this->_config['scope']}:{$key}" : $key, $offset);
 }
Пример #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)
 {
     return (bool) xcache_inc($this->settings['prefix'] . $group, 1);
 }
Пример #25
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)
 {
     return (bool) xcache_inc($this->_config['prefix'] . $group, 1);
 }
Пример #26
0
 public function increment($key, $step = 1)
 {
     return \xcache_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('xcache_groups', array('engine' => 'Xcache', 'duration' => 0, 'groups' => array('group_a', 'group_b'), 'prefix' => 'test_'));
     $this->assertTrue(Cache::write('test_groups', 'value', 'xcache_groups'));
     $this->assertEquals('value', Cache::read('test_groups', 'xcache_groups'));
     xcache_inc('test_group_a', 1);
     $this->assertFalse(Cache::read('test_groups', 'xcache_groups'));
     $this->assertTrue(Cache::write('test_groups', 'value2', 'xcache_groups'));
     $this->assertEquals('value2', Cache::read('test_groups', 'xcache_groups'));
     xcache_inc('test_group_b', 1);
     $this->assertFalse(Cache::read('test_groups', 'xcache_groups'));
     $this->assertTrue(Cache::write('test_groups', 'value3', 'xcache_groups'));
     $this->assertEquals('value3', Cache::read('test_groups', 'xcache_groups'));
 }
Пример #28
0
 /**
  * {@inheritdoc}
  */
 public function increment($name, $delta = 1)
 {
     return xcache_inc($this->options['prefix'] . $name, $delta);
 }
Пример #29
0
 public function inc($key, $interval = 1)
 {
     return xcache_inc($this->_p($key), $interval);
 }
Пример #30
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 = xcache_inc($storage_key, $value);
     if (!$r) {
         // it doesnt initialize counter by itself
         $this->counter_set($key, 0);
     }
     return $r;
 }