WordPress at a glance

wp_cache_set() WP 1.0

Saves the data to the cache.

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

  • See: WP_Object_Cache::set()
  • Global. WP_Object_Cache. $wp_object_cache Object cache global instance.
Works based on: WP_Object_Cache::set()
✈ 1 time = 0.000174s = fast | 50000 times = 1.98s = fast | PHP 7.1.11, WP 4.9.8

No Hooks.


true/false. False on failure, true on success


wp_cache_set( $key, $data, $group, $expire );
$key(int/string) (required)
The cache key to use for retrieval later.
$data(mixed) (required)
The contents to store in the cache.
Where to group the cache contents. Enables the same key to be used across groups.
Default: ''
When to expire the cache contents, in seconds.
Default: 0 (no expiration)

Code of wp cache set: wp-includes/cache.php VER 5.1.1

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

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

Related Functions

From tag: cache (caching)

No comments
    Hello, !     Log In . Register