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|stringrequired
What the contents in the cache are called.
$groupstringoptional
Where the cache contents are grouped. Default 'default'.

Default:'default'

$deprecatedbooloptional
Unused.

Default:false

Return

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

Source

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;
}

Changelog

VersionDescription
2.0.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.