wp_cache_get_multiple_salted( array $cache_keys, string $group, string|string[] $salt ): array

In this article

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

Parameters

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

Return

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

Source

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;
}

Changelog

VersionDescription
6.9.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.