Automattic\WooCommerce\Caching

WPCacheEngine::cache_objects()publicWC 1.0

Caches an object under a given key, and with a given expiration.

Method of the class: WPCacheEngine{}

No Hooks.

Return

Array. Array of return values, grouped by key. Each value is either true on success, or false on failure

Usage

$WPCacheEngine = new WPCacheEngine();
$WPCacheEngine->cache_objects( $objects, $expiration, $group ): array;
$objects(array) (required)
The objects to cache keyed by the key to cache under.
$expiration(int) (required)
Expiration for the cached object, in seconds.
$group(string)
The group under which the object will be cached.
Default: ''

WPCacheEngine::cache_objects() code WC 9.6.0

public function cache_objects( array $objects, int $expiration, string $group = '' ): array {
	$prefix = self::get_cache_prefix( $group );

	$objects = array_combine(
		array_map(
			function ( $key ) use ( $prefix ) {
				return $prefix . $key;
			},
			array_keys( $objects )
		),
		$objects,
	);

	return wp_cache_set_multiple( $objects, $group, $expiration );
}