wp_cache_set_salted()WP 6.9.0

Stores salted data in the cache.

No Hooks.

Returns

true|false. True on success, false on failure.

Usage

wp_cache_set_salted( $cache_key, $data, $group, $salt, $expire );
$cache_key(string) (required)
The cache key under which to store the data.
$data(mixed) (required)
The data to be cached.
$group(string) (required)
The cache group to which the data belongs.
$salt(string|string[]) (required)
The timestamp (or multiple timestamps if an array) indicating when the cache group(s) were last updated.
$expire(int)
When to expire the cache contents, in seconds.
Default: 0 (no expiration)

Changelog

Since 6.9.0 Introduced.

wp_cache_set_salted() code WP 6.9.1

function wp_cache_set_salted( $cache_key, $data, $group, $salt, $expire = 0 ) {
	$salt = is_array( $salt ) ? implode( ':', $salt ) : $salt;
	return wp_cache_set(
		$cache_key,
		array(
			'data' => $data,
			'salt' => $salt,
		),
		$group,
		$expire
	);
}