wp_cache_decr()WP 3.3.0

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

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

0

#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

Changelog

Since 3.3.0 Introduced.

wp_cache_decr() code WP 6.5.2

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

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