WordPress at a glance

wp_cache_replace() WP 1.0

Replaces the contents of the cache with new data.

1 time — 0.00012 sec (fast) | 50000 times — 1.23 sec (fast)

No Hooks.


true|false. False if original value does not exist, true if contents were replaced


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.
The group for the cache data that should be replaced.
Default: ''
When to expire the cache contents, in seconds.
Default: 0 (no expiration)


  • See: WP_Object_Cache::replace()
  • Global. WP_Object_Cache. $wp_object_cache Object cache global instance.


Since 2.0.0 Introduced.

Code of wp_cache_replace() WP 5.7.2

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

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

From tag: cache (caching)

No comments
    Log In