Title: WP_Object_Cache::get
Published: April 25, 2014
Last modified: February 24, 2026

---

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

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/WP_Object_Cache/get/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/WP_Object_Cache/get/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/WP_Object_Cache/get/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/WP_Object_Cache/get/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/WP_Object_Cache/get/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/WP_Object_Cache/get/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/WP_Object_Cache/get/?output_format=md#wp--skip-link--target)

Retrieves the cache contents, if it exists.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/WP_Object_Cache/get/?output_format=md#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](https://developer.wordpress.org/reference/classes/WP_Object_Cache/get/?output_format=md#parameters)󠁿

 `$key`int|stringrequired

The key under which the cache contents are stored.

`$group`stringoptional

Where the cache contents are grouped. Default `'default'`.

`$force`booloptional

Unused. Whether to force an update of the local cache from the persistent cache.

Default:`false`

`$found`bool|nulloptional

Whether the key was found in the cache (passed by reference).
 Disambiguates a return
of false, a storable value.

Default:`null`

## 󠀁[Return](https://developer.wordpress.org/reference/classes/WP_Object_Cache/get/?output_format=md#return)󠁿

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

## 󠀁[Source](https://developer.wordpress.org/reference/classes/WP_Object_Cache/get/?output_format=md#source)󠁿

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

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-object-cache.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-object-cache.php#L362)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-object-cache.php#L362-L388)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/WP_Object_Cache/get/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Object_Cache::is_valid_key()](https://developer.wordpress.org/reference/classes/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()](https://developer.wordpress.org/reference/classes/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 | Description | 
| [WP_Object_Cache::get_multiple()](https://developer.wordpress.org/reference/classes/wp_object_cache/get_multiple/)`wp-includes/class-wp-object-cache.php` |

Retrieves multiple values from the cache in one call.

  | 
| [wp_cache_get()](https://developer.wordpress.org/reference/functions/wp_cache_get/)`wp-includes/cache.php` |

Retrieves the cache contents from the cache by key and group.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/WP_Object_Cache/get/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.0.0](https://developer.wordpress.org/reference/since/2.0.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_object_cache%2Fget%2F)
before being able to contribute a note or feedback.