wp_cache_get() WordPress Function

The wp_cache_get() function is used to retrieve data from the WordPress object cache. This function is similar to the WordPress get_transient() function, but it can be used to retrieve any type of data from the cache, not just transient data.

wp_cache_get( int|string $key, string $group = '', bool $force = false, bool $found = null ) #

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


Description

Top ↑

See also


Top ↑

Parameters

$key

(int|string)(Required)The key under which the cache contents are stored.

$group

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

Default value: ''

$force

(bool)(Optional) Whether to force an update of the local cache from the persistent cache.

Default value: false

$found

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

Default value: null


Top ↑

Return

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


Top ↑

Source

File: wp-includes/cache.php

function wp_cache_get( $key, $group = '', $force = false, &$found = null ) {
	global $wp_object_cache;

	return $wp_object_cache->get( $key, $group, $force, $found );
}


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.