wp_cache_get

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

Description

(bool|mixed) wp_cache_get( (int|string) $key, (string) $group = '', (constant) $force = false, (null) &$found = null ); 

Returns (bool|mixed)

False on failure to retrieve contents or the cache contents on success

Parameters (4)

0. $key (int|string)
The key under which the cache contents are stored.
1. $group — Optional. (string) => ''
Where the cache contents are grouped. Default empty.
2. $force — Optional. (constant) => false
Whether to force an update of the local cache from the persistent cache. Default false.
3. $found — Optional. (null) => &$found = null
Whether the key was found in the cache. Disambiguates a return of false, a storable value. Passed by reference. Default null.

Usage

  1. if ( !function_exists( 'wp_cache_get' ) ) { 
  2. require_once ABSPATH . WPINC . '/cache.php'; 
  3.  
  4. // The key under which the cache contents are stored. 
  5. $key = null; 
  6.  
  7. // Optional. Where the cache contents are grouped. Default empty. 
  8. $group = ''; 
  9.  
  10. // Optional. Whether to force an update of the local cache from the persistent 
  11. // cache. Default false. 
  12. $force = false; 
  13.  
  14. // Optional. Whether the key was found in the cache. Disambiguates a return of false, 
  15. // a storable value. Passed by reference. Default null. 
  16. $found = &$found = null; 
  17.  
  18. // NOTICE! Understand what this does before running. 
  19. $result = wp_cache_get($key, $group, $force, $found); 
  20.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/cache.php  
  1. function wp_cache_get( $key, $group = '', $force = false, &$found = null ) { 
  2. global $wp_object_cache; 
  3.  
  4. return $wp_object_cache->get( $key, $group, $force, $found );