wp_suspend_cache_addition() WordPress Function

The wp_suspend_cache_addition() function allows you to add a new suspension to the cache. This is useful if you want to add a new suspension to the cache without having to first delete the existing cache.

wp_suspend_cache_addition( bool $suspend = null ) #

Temporarily suspend cache additions.


Description

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

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


Top ↑

Parameters

$suspend

(bool)(Optional) Suspends additions if true, re-enables them if false.

Default value: null


Top ↑

Return

(bool) The current suspend setting


Top ↑

Source

File: wp-includes/functions.php

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

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

	return $_suspend;
}


Top ↑

Changelog

Changelog
VersionDescription
3.3.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