lithium\storage\Cache::decrement()
Performs a decrement operation on specified numeric cache item from the given cache configuration.
Parameters
-
string
$name
Name of the cache configuration to use.
-
string
$key
Key of numeric cache item to decrement
-
integer
$offset
Offset to decrement - defaults to 1.
-
array
$options
Options for this method.
'conditions'
: A function or item that must return or evaluate totrue
in order to continue operation.
Returns
integer|booleanItem's new value on successful decrement, false otherwise.
Filter
This method can be filtered.
Source
public static function decrement($name, $key, $offset = 1, array $options = []) {
$options += ['conditions' => null];
if (is_callable($options['conditions']) && !$options['conditions']()) {
return false;
}
try {
$adapter = static::adapter($name);
} catch (ConfigException $e) {
return false;
}
$params = compact('key', 'offset');
return Filters::run(get_called_class(), __FUNCTION__, $params, function($params) use ($adapter) {
return $adapter->decrement($params['key'], $params['offset']);
});
}