wp_suspend_cache_invalidation() WordPress Function

The wp_suspend_cache_invalidation() function allows you to temporarily suspend cache invalidation for a specific object type. This can be useful when you need to make sure that changes to an object are not cached until you are ready to commit them.

wp_suspend_cache_invalidation( bool $suspend = true ) #

Suspend cache invalidation.


Description

Turns cache invalidation on and off. Useful during imports where you don’t want to do invalidations every time a post is inserted. Callers must be sure that what they are doing won’t lead to an inconsistent cache when invalidation is suspended.


Top ↑

Parameters

$suspend

(bool)(Optional) Whether to suspend or enable cache invalidation.

Default value: true


Top ↑

Return

(bool) The current suspend setting.


Top ↑

Source

File: wp-includes/functions.php

function wp_suspend_cache_invalidation( $suspend = true ) {
	global $_wp_suspend_cache_invalidation;

	$current_suspend                = $_wp_suspend_cache_invalidation;
	$_wp_suspend_cache_invalidation = $suspend;
	return $current_suspend;
}

Top ↑

Changelog

Changelog
VersionDescription
2.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More