wp_cache_replace()
Replaces the contents of the cache with new data.
1 time — 0.00012 sec (fast) | 50000 times — 1.23 sec (fast)
No Hooks.
Return
true|false
. False if original value does not exist, true if contents were replaced
Usage
wp_cache_replace( $key, $data, $group, $expire );
- $key(int|string) (required)
- The key for the cache data that should be replaced.
- $data(mixed) (required)
- The new data to store in the cache.
- $group(string)
- The group for the cache data that should be replaced.
Default: '' - $expire(int)
- When to expire the cache contents, in seconds.
Default: 0 (no expiration)
Notes
- See: WP_Object_Cache::replace()
- Global. WP_Object_Cache. $wp_object_cache Object cache global instance.
Changelog
Since 2.0.0 | Introduced. |
Code of wp_cache_replace() wp cache replace WP 5.9.3
function wp_cache_replace( $key, $data, $group = '', $expire = 0 ) { global $wp_object_cache; return $wp_object_cache->replace( $key, $data, $group, (int) $expire ); }