Esempio n. 1
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;
 }
Esempio n. 2
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;
 }
Esempio n. 3
0
 /**
  * Decrements 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 int $offset How much to subtract
  * @return New decremented value, false otherwise
  */
 public function decrement($key, $offset = 1)
 {
     return xcache_dec($key, $offset);
 }
Esempio n. 4
0
 /**
  * Decrements 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 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 xcache_dec($key, $offset);
 }
Esempio n. 5
0
 /**
  * Performs an atomic decrement 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.
  * It is possible to decrement a value into the negative integers.
  *
  * @param string $key Key of numeric cache item to decrement.
  * @param integer $offset Offset to decrement - defaults to `1`.
  * @return integer|boolean The item's new value on successful decrement, else `false`.
  */
 public function decrement($key, $offset = 1)
 {
     return xcache_dec($this->_config['scope'] ? "{$this->_config['scope']}:{$key}" : $key, $offset);
 }
Esempio n. 6
0
 /**
  * Performs an atomic decrement 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.
  * It is possible to decrement a value into the negative integers.
  *
  * @param string $key Key of numeric cache item to decrement
  * @param integer $offset Offset to decrement - defaults to 1.
  * @return mixed Item's new value on successful decrement, false otherwise
  */
 public function decrement($key, $offset = 1)
 {
     return function ($self, $params, $chain) use($offset) {
         extract($params);
         return xcache_dec($key, $offset);
     };
 }
Esempio n. 7
0
 public function dec($key, $step = 1)
 {
     $this->type = $type;
     return xcache_dec($this->_key($key), $step);
 }
Esempio n. 8
0
 /**
  * {@inheritdoc}
  */
 public function decrement($name, $delta = 1)
 {
     return xcache_dec($this->options['prefix'] . $name, $delta);
 }
Esempio n. 9
0
 /**
  * @see Temporary_cache_driver::dec()
  */
 public function dec($id, $realm = COT_DEFAULT_REALM, $value = 1)
 {
     return xcache_dec($realm . '/' . $id, $value);
 }
Esempio n. 10
0
 public function decrement($key, $step = 1)
 {
     return \xcache_dec($key, $step);
 }
Esempio n. 11
0
 /**
  * Decreases the value in the variable store
  * @param string $key The key of the variable
  * @param integer $value The value to decrease 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 decrease($key, $value = null, $timeToLive = null)
 {
     return xcache_dec($key, $value, $timeToLive);
 }
Esempio n. 12
0
 static function intdec($key, $value, $ttl)
 {
     return xcache_dec($key, $value, $ttl);
 }
Esempio n. 13
0
 public function decr($id, $val = 1, $group = Cache::DEFAULT_GROUP, $ttl = Cache::DEFAULT_TTL)
 {
     return xcache_dec($this->getPrefix($group) . $id, $val, $ttl);
 }
Esempio n. 14
0
 /**
  * Decrements numeric cache item's value.
  *
  * {@inheritDoc}
  *
  * @see \app\src\Cache\etsis_Abstract_Cache::dec()
  *
  * @since 6.2.0
  * @param int|string $key
  *            The cache key to decrement.
  * @param int $offset
  *            Optional. The amount by which to decrement the item's value. Default: 1.
  * @param string $namespace
  *            Optional. The namespace the key is in. Default: 'default'.
  * @return false|int False on failure, the item's new value on success.
  */
 public function dec($key, $offset = 1, $namespace = 'default')
 {
     $unique_key = $this->uniqueKey($key, $namespace);
     return xcache_dec($unique_key, (int) $offset);
 }
Esempio n. 15
0
 public function decr($id, $value = 1, $ttl = Cache::DEFAULT_TTL)
 {
     return xcache_dec($this->prefix . $id, $value, $ttl);
 }
Esempio n. 16
0
 public function delete($key)
 {
     xcache_dec('__known_xcache_size', strlen($this->load($key)));
     return xcache_unset($key);
 }
Esempio n. 17
0
 /**
  * Decrease 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 decr($key, $amount)
 {
     return xcache_dec($key, $amount);
 }
Esempio n. 18
0
 /**
  * Increment the value of an item in the cache.
  *
  * @param  string  $key
  * @param  mixed   $value
  * @return int
  */
 public function decrement($key, $value = 1)
 {
     return xcache_dec($this->getPrefixWithLocale() . $key, $value);
 }
Esempio n. 19
0
 /**
  * Increment the value of an item in the cache.
  *
  * @param  string  $key
  * @param  mixed   $value
  * @return void
  */
 public function decrement($key, $value = 1)
 {
     return xcache_dec($this->prefix . $key, $value);
 }
Esempio n. 20
0
 /**
  * Emulates `Memcache::decrement`.
  */
 public function decrement($key, $value = 1)
 {
     return xcache_dec(self::$key_prefix . $key, $value);
 }
Esempio n. 21
0
 /**
  * Decrease a stored number
  *
  * @param string $key
  * @param int $step
  * @return int | bool
  */
 public function dec($key, $step = 1)
 {
     return xcache_dec($this->getPrefix() . $key, $step);
 }
Esempio n. 22
0
 /**
  * {@inheritdoc}
  */
 public function dec($name, $delta = 1)
 {
     return xcache_dec($this->prefix . $name, $delta);
 }
Esempio n. 23
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;
     $ttl = $options->getTtl();
     $value = (int) $value;
     return xcache_dec($internalKey, $value, $ttl);
 }
Esempio n. 24
0
 function decrement($key, $by = 1)
 {
     $formatted = \Cachet\Helper::formatKey([$this->prefix, 'counter', $key]);
     $value = xcache_dec($formatted, $by, $this->counterTTL);
     return $value;
 }
Esempio n. 25
0
 public function decr($key, $value = 1)
 {
     return xcache_dec($key, $value);
 }
Esempio n. 26
0
 /**
  * Performs an atomic decrement 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.
  * It is possible to decrement a value into the negative integers.
  *
  * @param string $key Key of numeric cache item to decrement
  * @param integer $offset Offset to decrement - defaults to 1.
  * @return closure Function returning item's new value on successful decrement, else `false`
  */
 public function decrement($key, $offset = 1)
 {
     return function ($self, $params) use($offset) {
         return xcache_dec($params['key'], $offset);
     };
 }
Esempio n. 27
0
 public function dec($key, $step = 1)
 {
     return xcache_dec($key, $step);
 }
Esempio n. 28
0
 }
 private static function xcache_increment($name, $step = 1)
 {
     $orgi = $name;
     $name = self::getMemoryName($name);
     $ret = xcache_inc($name, $step);
     if ($ret === false) {
         self::xcache_set($orgi, $step, 3600);
         return $step;
     } else {
         return $ret;
     }
Esempio n. 29
0
 public function dec($key, $interval = 1)
 {
     return xcache_dec($this->_p($key), $interval);
 }
Esempio n. 30
0
 /**
  * {@inheritdoc}
  */
 protected function decrementValue($key, $value)
 {
     if (is_int($dec = xcache_dec($key, (int) $value))) {
         return $dec;
     }
     return false;
 }