wp_cache_delete()WP 2.0.0

Removes the cache contents matching key and group.

No Hooks.

Return

true|false. True on successful removal, false on failure.

Usage

wp_cache_delete( $key, $group );
$key(int|string) (required)
What the contents in the cache are called.
$group(string)
Where the cache contents are grouped.
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.5.2

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

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