wp_cache_set

Advertisement

Summery Summery

Saves the data to the cache.

Syntax Syntax

wp_cache_set( int|string $key, mixed $data, string $group = '', int $expire )

Description Description

Differs from wp_cache_add() and wp_cache_replace() in that it will always write data.

Parameters Parameters

$key

(int|string) (Required) The cache key to use for retrieval later.

$data

(mixed) (Required) The contents to store in the cache.

$group

(string) (Optional) Where to group the cache contents. Enables the same key to be used across groups.

Default value: ''

$expire

(int) (Optional) When to expire the cache contents, in seconds. Default 0 (no expiration).

Return Return

(bool) True on success, false on failure.

Source Source

File: wp-includes/cache.php

function wp_cache_set( $key, $data, $group = '', $expire = 0 ) {
	global $wp_object_cache;

	return $wp_object_cache->set( $key, $data, $group, (int) $expire );
}

Advertisement

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

See also See also

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.