wp_cache_add() – Adds data to the cache, if the cache key doesn’t already exist.

You appear to be a bot. Output may be restricted


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


$bool = wp_cache_add( $key, $data, $group, $expire );


( int|string ) required – The cache key to use for retrieval later.
( mixed ) required – The data to add to the cache.
( string ) optional – Optional. The group to add the cache to. Enables the same key to be used across groups. Default empty.
( int ) optional – Optional. When the cache data should expire, in seconds. Default 0 (no expiration).


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


File name: wordpress/wp-includes/cache.php

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

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

 View on GitHub View on Trac