wp_cache_replace() WordPress Function
wp_cache_replace() is a function used in WordPress to replace a cached object with new data. This function is useful when you need to update the data in a cached object, but do not want to delete the entire cache.
wp_cache_replace( int|string $key, mixed $data, string $group = '', int $expire ) #
Replaces the contents of the cache with new data.
Description
See also
Parameters
- $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)(Optional) The group for the cache data that should be replaced.
Default value: ''
- $expire
(int)(Optional) When to expire the cache contents, in seconds. Default 0 (no expiration).
Return
(bool) True if contents were replaced, false if original value does not exist.
Source
File: wp-includes/cache.php
function wp_cache_replace( $key, $data, $group = '', $expire = 0 ) { global $wp_object_cache; return $wp_object_cache->replace( $key, $data, $group, (int) $expire ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |