wp_cache_delete()
Removes the cache contents matching key and group.
Uses: WP_Object_Cache()
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
#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
- See: WP_Object_Cache::delete()
- Global. WP_Object_Cache. $wp_object_cache Object cache global instance.
Changelog
Since 2.0.0 | Introduced. |
wp_cache_delete() wp cache delete code WP 6.1.1
function wp_cache_delete( $key, $group = '' ) { global $wp_object_cache; return $wp_object_cache->delete( $key, $group ); }