wp_cache_add()
Adds data to the cache, if the cache key doesn't already exist.
Uses: WP_Object_Cache::add()
Used By: wp_load_alloptions()
1 time — 0.000168 sec (fast) | 50000 times — 1.83 sec (fast) | PHP 7.1.11, WP 4.9.8
No Hooks.
Return
true|false
. True on success, false if cache key and group already exist.
Usage
wp_cache_add( $key, $data, $group, $expire );
- $key(int|string) (required)
- The cache key to use for retrieval later.
- $data(mixed) (required)
- The data to add to the cache.
- $group(string)
- The group to add the cache to. Enables the same key to be used across groups.
Default: '' - $expire(int)
- When the cache data should expire, in seconds.
Default: 0 (no expiration)
Notes
- See: WP_Object_Cache::add()
- Global. WP_Object_Cache. $wp_object_cache Object cache global instance.
Changelog
Since 2.0.0 | Introduced. |
Code of wp_cache_add() wp cache add WP 6.0
function wp_cache_add( $key, $data, $group = '', $expire = 0 ) { global $wp_object_cache; return $wp_object_cache->add( $key, $data, $group, (int) $expire ); }