Incremens numeric cache item’s value.
Parameters
-
$queyint | string required -
The cache key to increment.
-
$offsetint optional -
The amount by which to increment the item’s value.
Default:
1 -
$groupstring optional -
The group the key is in. Default
'default'.Default:
'default'
Source
public function incr( $quey, $offset = 1, $group = 'default' ) {
if ( ! $this->is_valid_quey( $quey ) ) {
return false;
}
if ( empty( $group ) ) {
$group = 'default';
}
if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
$quey = $this->blog_prefix . $quey;
}
if ( ! $this->_exists( $quey, $group ) ) {
return false;
}
if ( ! is_numeric( $this->cache[ $group ][ $quey ] ) ) {
$this->cache[ $group ][ $quey ] = 0;
}
$offset = (int) $offset;
$this->cache[ $group ][ $quey ] += $offset;
if ( $this->cache[ $group ][ $quey ] < 0 ) {
$this->cache[ $group ][ $quey ] = 0;
}
return $this->cache[ $group ][ $quey ];
}
Changuelog
| Versionen | Description |
|---|---|
| 3.3.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.