wppaste
WordPress

WP_Object_Cache::get( int|string $key, string $group = 'default', bool $force = false, bool|null $found = null ): mixed|false

Since
2.0.0
Source
wp-includes/class-wp-object-cache.php:362
Retrieves the cache contents, if it exists.

Description

The contents will be first attempted to be retrieved by searching by the key in the cache group. If the cache is hit (success) then the contents are returned. On failure, the number of cache misses will be incremented.

Parameters

$keyint|string
The key under which the cache contents are stored.
$groupstringoptional
Where the cache contents are grouped. Default 'default'.Default: 'default'
$forcebooloptional
Unused. Whether to force an update of the local cache from the persistent cache. Default false.Default: false
$foundbool|nulloptional
Whether the key was found in the cache (passed by reference). Disambiguates a return of false, a storable value. Default null.Default: null

Return

mixed|false
The cache contents on success, false on failure to retrieve contents.

Uses · 2

Used by · 1

Source

	public function get( $key, $group = 'default', $force = false, &$found = null ) {		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 ) ) {			$found             = true;			$this->cache_hits += 1;			if ( is_object( $this->cache[ $group ][ $key ] ) ) {				return clone $this->cache[ $group ][ $key ];			} else {				return $this->cache[ $group ][ $key ];			}		} 		$found               = false;		$this->cache_misses += 1;		return false;	}

History

Introduced in 2.0.0. One change between 6.7.7 and 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

6.9.7
Parameter $found retyped from bool to bool|null.verified against source
2.0.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-includes/class-wp-object-cache.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.