WP_Object_Cache::decr
Decrements numeric cache item's value.
Метод класса: WP_Object_Cache{}
Хуков нет.
Возвращает
int|false. The item's new value on success, false on failure.
Использование
$WP_Object_Cache = new WP_Object_Cache(); $WP_Object_Cache->decr( $key, $offset, $group );
- $key(int|строка) (обязательный)
- The cache key to decrement.
- $offset(int)
- The amount by which to decrement the item's value.
По умолчанию:1 - $group(строка)
- The group the key is in.
По умолчанию:'default'
Список изменений
| С версии 3.3.0 | Введена. |
Код WP_Object_Cache::decr() WP Object Cache::decr WP 6.9.4
public function decr( $key, $offset = 1, $group = 'default' ) {
if ( ! $this->is_valid_key( $key ) ) {
return false;
}
if ( empty( $group ) ) {
$group = 'default';
}
if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
$key = $this->blog_prefix . $key;
}
if ( ! $this->_exists( $key, $group ) ) {
return false;
}
if ( ! is_numeric( $this->cache[ $group ][ $key ] ) ) {
$this->cache[ $group ][ $key ] = 0;
}
$offset = (int) $offset;
$this->cache[ $group ][ $key ] -= $offset;
if ( $this->cache[ $group ][ $key ] < 0 ) {
$this->cache[ $group ][ $key ] = 0;
}
return $this->cache[ $group ][ $key ];
}