WP_Object_Cache::delete() WordPress Method

The WP_Object_Cache::delete() method is used to delete an object from the cache. This method takes a single parameter, which is the key of the object to be deleted.

WP_Object_Cache::delete( int|string $key, string $group = 'default', bool $deprecated = false ) #

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.


Top ↑

Parameters

$key

(int|string)(Required)What the contents in the cache are called.

$group

(string)(Optional) Where the cache contents are grouped.

Default value: 'default'

$deprecated

(bool)(Optional) Unused.

Default value: false


Top ↑

Return

(bool) True on success, false if the contents were not deleted.


Top ↑

Source

File: wp-includes/class-wp-object-cache.php

	public function delete( $key, $group = 'default', $deprecated = 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;
	}


Top ↑

Changelog

Changelog
VersionDescription
2.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.