wp_cache_delete()WP 2.0.0

Deletes the cache by the specified key and group.

This function can be overridden by plugins. If you are using an object caching plugin, this function may work a little differently because its operation is defined separately. And this description shows how the basic WordPress function works.

No Hooks.

Returns

true|false. Boolean: true if the cache was successfully deleted and false on failure.

Usage

wp_cache_delete( $key, $group );
$key(number/string) (required)
The cache key to delete.
$group(string)
The name of the group in which to search for the specified key.
Default: ''

Examples

0

#1 Delete the previously set cache

This is a code snippet from the function clean_post_cache(). Here we remove cache of post 23, which was set into the 'posts' and 'post_meta' groups:

$post_id = 23;
wp_cache_delete( $post_id, 'posts' );
wp_cache_delete( $post_id, 'post_meta' );

Notes

Changelog

Since 2.0.0 Introduced.

wp_cache_delete() code WP 6.8.1

function wp_cache_delete( $key, $group = '' ) {
	global $wp_object_cache;

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