wp_cache_add_global_groups()WP 2.6.0

Adds a group or set of groups to the list of global groups.

No Hooks.

Return

null. Nothing (null).

Usage

wp_cache_add_global_groups( $groups );
$groups(string|string[]) (required)
A group or an array of groups to add.

Examples

0

#1 Example of adding a global group

Suppose we have created an entity with its own table in the database and a separate table with metadata. The entity is called 'tests'. The metadata is controlled by WP functions: add_metadata(), get_metadata() etc.

Now, we need to make the data stored in the cache of this entity be the same for the whole sites network, not different for different sites in the network. To do this, let's create the global group tests_meta (group is specified when adding the metadata cache).

wp_cache_add_global_groups( 'tests_meta' );

Now when adding or retrieve data using add_metadata( 'tests', ... ) and get_metadata( 'tests', ... ) the cache will be the same among all sites in Multisite network.

Notes

Changelog

Since 2.6.0 Introduced.

wp_cache_add_global_groups() code WP 6.4.3

function wp_cache_add_global_groups( $groups ) {
	global $wp_object_cache;

	$wp_object_cache->add_global_groups( $groups );
}