bp_core_set_incremented_cache

Caches a value using an incremented key.

Description

bp_core_set_incremented_cache( (string) $key, (string) $group, (array) $ids ); 

An incremented key is a cache key that is hashed with a unique incrementor, allowing for bulk invalidation.

Use this method when caching data that should be invalidated whenever any object of a given type is created, updated, or deleted. This usually means data related to object queries, which can only reliably cached until the underlying set of objects has been modified. See, eg, BP_Activity_Activity::get().

Parameters (3)

0. $key (string)
Unique key for the query. Usually a SQL string.
1. $group (string)
Cache group. Eg bp_activity..
2. $ids (array)
Array of IDs.

Usage

  1. if ( !function_exists( 'bp_core_set_incremented_cache' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-cache.php'; 
  3.  
  4. // Unique key for the query. Usually a SQL string. 
  5. $key = ''; 
  6.  
  7. // Cache group. Eg 'bp_activity'. 
  8. $group = ''; 
  9.  
  10. // Array of IDs. 
  11. $ids = array(); 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bp_core_set_incremented_cache($key, $group, $ids); 
  15.  

Defined (1)

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

/bp-core/bp-core-cache.php  
  1. function bp_core_set_incremented_cache( $key, $group, $ids ) { 
  2. $cache_key = bp_core_get_incremented_cache_key( $key, $group ); 
  3. return wp_cache_set( $cache_key, $ids, $group );