Summery Summery

Adds data to the cache, if the cache key doesn’t already exist.

Syntax Syntax

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

Parameters Parameters


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


(Required) The data to add to the cache.


(Optional) The group to add the cache to. Enables the same key to be used across groups.

Default value: ''


(Optional) When the cache data should expire, in seconds. Default 0 (no expiration).

Return Return

(bool) True on success, false if cache key and group already exist.

Source Source

File: wp-includes/cache.php

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

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


Changelog Changelog

Version Description
2.0.0 Introduced.

See also See also


Leave a Reply