本文整理汇总了PHP中apc_dec函数的典型用法代码示例。如果您正苦于以下问题:PHP apc_dec函数的具体用法?PHP apc_dec怎么用?PHP apc_dec使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了apc_dec函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: decrement
public function decrement($k, $step = 1)
{
if ($this->core) {
return $this->core->decrement($k, $step);
}
return apc_dec($k, $step);
}
示例2: dec
public function dec($key, $step = 1, $success = TRUE)
{
if (_cacheStatus) {
apc_dec($key, $step, $success);
}
return FALSE;
}
示例3: dec
public function dec($key, $step = 1, $success = true)
{
if (CACHE_STATUS) {
apc_dec($key, $step, $success);
}
return false;
}
示例4: dec
public function dec($key, $expire = 0)
{
$key = $this->buildKey($key);
if (apc_dec($key) === false) {
return apc_store($key, 0, $expire);
}
return true;
}
示例5: dec
public function dec($key, $step = 1)
{
$this->type = $type;
if (apc_dec($this->_key($key), $step) !== FALSE) {
return apc_fetch($this->_key($key));
}
return FALSE;
}
示例6: decrement
/**
* {@inheritdoc}
*/
public function decrement($key, $amount = 1)
{
$result = apc_dec($this->getKey($key), $amount);
if ($result < 0) {
$result = 0;
$this->set($key, $result);
}
return $result;
}
示例7: decrease
/**
* 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)
{
if ($value === null) {
$value = 1;
}
// make sure the variable exists
apc_add($key, 0);
return apc_dec($key, $value);
}
示例8: testAPC
public function testAPC()
{
$key = 'APCPolyfillTest';
apc_store($key, 1);
apc_inc($key, 2);
apc_dec($key);
$this->assertEquals(apc_fetch($key, $success), 2);
$this->assertTrue($success);
apc_delete($key);
apc_fetch($key, $success);
$this->assertFalse($success);
}
示例9: internalDecrementItem
/**
* Internal method to decrement an item.
*
* @param string $normalizedKey
* @param int $value
* @return int|boolean The new value on success, false on failure
* @throws Exception\ExceptionInterface
*/
protected function internalDecrementItem(&$normalizedKey, &$value)
{
$options = $this->getOptions();
$prefix = $options->getNamespace() . $options->getNamespaceSeparator();
$internalKey = $prefix . $normalizedKey;
$value = (int) $value;
$newValue = apc_dec($internalKey, $value);
// initial value
if ($newValue === false) {
$ttl = $options->getTtl();
$newValue = -$value;
if (!apc_add($internalKey, $newValue, $ttl)) {
throw new Exception\RuntimeException("apc_add('{$internalKey}', {$newValue}, {$ttl}) failed");
}
}
return $newValue;
}
示例10: dec
public function dec($key, $step = 1)
{
$this->type = $type;
return apc_dec($this->_key($key), $step) !== false ? apc_fetch($this->_key($key)) : false;
}
示例11: decrement
/**
* @inheritdoc
*/
public function decrement($key, $offset = 1, $expire = 0, $create = true)
{
$hash = $this->prepareKey($key);
if ($this->exists($key) === false) {
if ($create === false) {
return false;
}
apc_add($hash, 0, $expire);
}
return apc_dec($hash, $offset);
}
示例12: dec
public function dec($key, $interval = 1)
{
return apc_dec($this->_p($key), $interval);
}
示例13: decrement
/**
* Decrements the value of an integer cached key
*
* @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 apc_dec($key, $offset);
}
示例14: decrement
/**
* {@inheritdoc}
*/
public function decrement($counter, $number = 1)
{
$counter = $this->transform($counter);
$value = apc_dec($this->prefix . '/' . $counter->getName(), $number);
return $this->handleDecrement($value, $counter, $number);
}
示例15: decrement
/**
* Performs an atomic decrement operation on specified numeric cache item.
*
* Note that, as per the APC specification:
* If the item's value is not numeric, the decrement operation has no effect
* on the key - it retains it's original non-integer value.
*
* @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) {
return apc_dec($params['key'], $offset);
};
}