WordPress at a glance

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

Works based on: WP_Object_Cache::decr()

No Hooks.

Return

false/Int. False on failure, the item's new value on success.

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

Decrement the value of the cache item 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.

Code of wp cache decr: wp-includes/cache.php WP 5.2.2

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

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

Related Functions

From tag: cache (caching)

No comments
    Hello, !     Log In . Register