wp_cache_get_multiple_salted()WP 6.9.0

Retrieves multiple items from the cache, only considering valid and unchanged items.

No Hooks.

Returns

Array. An associative array containing cache values. Values are false if they are not found or outdated.

Usage

wp_cache_get_multiple_salted( $cache_keys, $group, $salt );
$cache_keys(array) (required)
Array of cache keys to retrieve.
$group(string) (required)
The group of the cache to check.
$salt(string|string[]) (required)
The timestamp (or multiple timestamps if an array) indicating when the cache group(s) were last updated.

Changelog

Since 6.9.0 Introduced.

wp_cache_get_multiple_salted() code WP 6.9.1

function wp_cache_get_multiple_salted( $cache_keys, $group, $salt ) {
	$salt  = is_array( $salt ) ? implode( ':', $salt ) : $salt;
	$cache = wp_cache_get_multiple( $cache_keys, $group );

	foreach ( $cache as $key => $value ) {
		if ( ! is_array( $value ) ) {
			$cache[ $key ] = false;
			continue;
		}
		if ( ! isset( $value['salt'], $value['data'] ) || $salt !== $value['salt'] ) {
			$cache[ $key ] = false;
			continue;
		}
		$cache[ $key ] = $value['data'];
	}

	return $cache;
}