wp_cache_decr()
Decrements the value of the numeric cache item with the specified key and group.
If you want to increment the value of the numeric cache item, use wp_cache_incr().
Uses: WP_Object_Cache::decr()
No Hooks.
Return
Int|false
. The item's new value on success, false on failure.
Usage
wp_cache_decr( $key, $offset, $group );
- $key(int|string) (required)
- The cache key to decrement.
- $offset(int)
- The amount by which to decrement the item's value.
Default: 1 - $group(string)
- The group the key is in.
Default: ''
Examples
#1 Decrement cache value
Reduce the cache value in the group my_group
with the key my_key
by 10:
wp_cache_decr( 'my_key', 10, 'my_group' );
Notes
- See: WP_Object_Cache::decr()
- Global. WP_Object_Cache. $wp_object_cache Object cache global instance.
Changelog
Since 3.3.0 | Introduced. |
wp_cache_decr() wp cache decr code WP 6.7.2
function wp_cache_decr( $key, $offset = 1, $group = '' ) { global $wp_object_cache; return $wp_object_cache->decr( $key, $offset, $group ); }