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().

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

0

#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

Changelog

Since 3.3.0 Introduced.

wp_cache_incr() code WP 6.6.2

function wp_cache_incr( $key, $offset = 1, $group = '' ) {
	global $wp_object_cache;

	return $wp_object_cache->incr( $key, $offset, $group );
}