wp_cache_add

Adds data to the cache, if the cache key doesn't already exist.

Description

wp_cache_add( (int|string) $key, (mixed) $data, (string) $flag = '', (int) $expire = 0 ); 

Parameters (4)

0. $key (int|string)
The cache ID to use for retrieval later
1. $data (mixed)
The data to add to the cache store
2. $flag — Optional. (string) => ''
The group to add the cache to
3. $expire — Optional. (int)
When the cache data should be expired

Usage

  1. if ( !function_exists( 'wp_cache_add' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/backpress/functions.wp-object-cache.php'; 
  3.  
  4. // The cache ID to use for retrieval later 
  5. $key = null; 
  6.  
  7. // The data to add to the cache store 
  8. $data = null; 
  9.  
  10. // The group to add the cache to 
  11. $flag = ''; 
  12.  
  13. // When the cache data should be expired 
  14. $expire = -1; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = wp_cache_add($key, $data, $flag, $expire); 
  18.  

Defined (1)

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

/bp-forums/bbpress/bb-includes/backpress/functions.wp-object-cache.php  
  1. function wp_cache_add($key, $data, $flag = '', $expire = 0) { 
  2. global $wp_object_cache; 
  3.  
  4. return $wp_object_cache->add($key, $data, $flag, $expire);