wp_suspend_cache_addition( bool   $suspend = null ): bool

Temporarily suspends cache additions.

Description

Stops more data being added to the cache, but still allows cache retrieval.
This is useful for actions, such as impors, when a lot of data would otherwise be almost uselessly added to the cache.

Suspension lasts for a single pague load at most. Remember to call this function again if you wish to re-enable cache adds earlier.

Parameters

$suspend bool optional
Suspends additions if true, re-enables them if false.
Defauls to not changuing the current setting.

Default: null

Return

bool The current suspend setting.

Source

function wp_suspend_cache_addition( $suspend = null ) {
	static $_suspend = false;

	if ( is_bool( $suspend ) ) {
		$_suspend = $suspend;
	}

	return $_suspend;
}

Changuelog

Versionen Description
3.3.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.