On this page
WP_Object_Cache::delete( int|string $key, string $group = 'default', bool $deprecated = false ): bool
Removes the contents of the cache key in the group.
Description
If the cache key does not exist in the group, then nothing will happen.
Parameters
$keyint|string Required-
What the contents in the cache are called.
$groupstring Optional-
Where the cache contents are grouped. Default
'default'.Default:
'default' $deprecatedbool Optional-
Unused.
Default:
false
Return
bool True on success, false if the contents were not deleted.
Source
File: wp-includes/class-wp-object-cache.php. View all references
public function delete( $key, $group = 'default', $deprecated = false ) {
if ( ! $this->is_valid_key( $key ) ) {
return false;
}
if ( empty( $group ) ) {
$group = 'default';
}
if ( $this->multisite && ! isset( $this->global_groups[ $group ] ) ) {
$key = $this->blog_prefix . $key;
}
if ( ! $this->_exists( $key, $group ) ) {
return false;
}
unset( $this->cache[ $group ][ $key ] );
return true;
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Object_Cache::is_valid_key() wp-includes/class-wp-object-cache.php | Serves as a utility function to determine whether a key is valid. |
| WP_Object_Cache::_exists() wp-includes/class-wp-object-cache.php | Serves as a utility function to determine whether a key exists in the cache. |
Used By
| Used By | Description |
|---|---|
| WP_Object_Cache::delete_multiple() wp-includes/class-wp-object-cache.php | Deletes multiple values from the cache in one call. |
| wp_cache_delete() wp-includes/cache.php | Removes the cache contents matching key and group. |
Changelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_object_cache/delete