wp_cache_incr()
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().
Uses: WP_Object_Cache::incr()
No Hooks.
Returns
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 the cache value
Increase the cache value 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. |
wp_cache_incr() wp cache incr code WP 6.8.3
function wp_cache_incr( $key, $offset = 1, $group = '' ) {
global $wp_object_cache;
return $wp_object_cache->incr( $key, $offset, $group );
}