wp_cache_incr() WP 3.3.0
Increments the value of the numeric cache item with the specified cache key and group.
If you want to decrement the value of the numeric cache item, use wp_cache_decr().
Works based on: WP_Object_Cache::incr()
No Hooks.
Return
Int/false. The item's new value on success, false on failure.
Usage
wp_cache_incr( $key, $offset, $group );
- $key(int/string) (required)
- The key for the cache contents that should be incremented.
- $offset(int)
- The amount by which to increment the item's value.
Default: 1 - $group(string)
- The group the key is in.
Default: ''
Examples
#1 Increment cache value
Increment the value of the cache item in the group my_group
with the key my_key
by 10.
wp_cache_incr( 'my_key', 10, 'my_group' );
Notes
- See: WP_Object_Cache::incr()
- Global. WP_Object_Cache. $wp_object_cache Object cache global instance.
Changelog
Since 3.3.0 | Introduced. |
Code of wp_cache_incr() wp cache incr WP 5.6
function wp_cache_incr( $key, $offset = 1, $group = '' ) {
global $wp_object_cache;
return $wp_object_cache->incr( $key, $offset, $group );
}