wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_cache_get_salted › WordPress Function

Seit6.9.0
Veraltetn/v
wp_cache_get_salted ( $cache_key, $group, $salt )
Parameter: (3)
  • (string) $cache_key The cache key used for storage and retrieval.
    Erforderlich: Ja
  • (string) $group The cache group used for organizing data.
    Erforderlich: Ja
  • (string|string[]) $salt The timestamp (or multiple timestamps if an array) indicating when the cache group(s) were last updated.
    Erforderlich: Ja
Gibt zurück:
  • (mixed|false) The cached data if valid, or false if the cache does not exist or is outdated.
Definiert in:
Codex:

Retrieves cached data if valid and unchanged.



Quellcode

function wp_cache_get_salted( $cache_key, $group, $salt ) {
		$salt  = is_array( $salt ) ? implode( ':', $salt ) : $salt;
		$cache = wp_cache_get( $cache_key, $group );

		if ( ! is_array( $cache ) ) {
			return false;
		}

		if ( ! isset( $cache['salt'] ) || ! isset( $cache['data'] ) || $salt !== $cache['salt'] ) {
			return false;
		}

		return $cache['data'];
	}
endif;

if ( ! function_exists( 'wp_cache_set_salted' ) ) :
	/**
	 * Stores salted data in the cache.
	 *
	 * @since 6.9.0
	 *
	 * @param string          $cache_key The cache key under which to store the data.
	 * @param mixed           $data      The data to be cached.
	 * @param string          $group     The cache group to which the data belongs.
	 * @param string|string[] $salt      The timestamp (or multiple timestamps if an array) indicating when the cache group(s) were last updated.
	 * @param int             $expire    Optional. When to expire the cache contents, in seconds.
	 *                                   Default 0 (no expiration).
	 * @return bool True on success, false on failure.
	 */