wp_cache_add_non_persistent_groups()
Marks the specified group/groups as non-persistent cache, i.e., which does not need to be saved for inter-session use.
Not saving the cache between sessions is useful when you need to add data to the cache that is only used during the current page generation or script execution. These can be changing data intended for just one page generation.
By default, in WordPress, all caching is non-persistent and is created anew each time during each page generation. But there are plugins that redesign the WP cache structure so that it is saved (usually to disk) and used even before the page generation begins (session).
IMPORTANT: not all object caching plugins implement this function!
The groups in question are specified in the third parameter of the caching functions when adding cache: wp_cache_add( $key, $data, $group );
No Hooks.
Returns
null. Defined in the plugin that describes this function.
Usage
wp_cache_add_non_persistent_groups( $groups );
- $groups(string/array) (required)
- The name or array of names of groups that do not need to be saved in persistent cache.
Examples
#1 Add non-permanent object cache groups
wp_cache_add_non_persistent_groups( [ 'special', 'foo', 'bar' ] );
Changelog
| Since 2.6.0 | Introduced. |
wp_cache_add_non_persistent_groups() wp cache add non persistent groups code WP 6.9.1
function wp_cache_add_non_persistent_groups( $groups ) {
// Default cache doesn't persist so nothing to do here.
}