Automattic\WooCommerce\Internal\ProductFeed\Utils

MemoryManager::flush_cachespublicWC 10.5.0

Flush all caches.

Method of the class: MemoryManager{}

No Hooks.

Returns

null. Nothing (null).

Usage

$MemoryManager = new MemoryManager();
$MemoryManager->flush_caches(): void;

Changelog

Since 10.5.0 Introduced.

MemoryManager::flush_caches() code WC 10.8.1

public function flush_caches(): void {
	global $wpdb, $wp_object_cache;

	$wpdb->queries = array();

	wp_cache_flush();

	if ( ! is_object( $wp_object_cache ) ) {
		return;
	}

	// These properties exist on various object cache implementations.
	$wp_object_cache->group_ops      = array(); // @phpstan-ignore property.notFound
	$wp_object_cache->stats          = array(); // @phpstan-ignore property.notFound
	$wp_object_cache->memcache_debug = array(); // @phpstan-ignore property.notFound
	$wp_object_cache->cache          = array(); // @phpstan-ignore property.notFound

	// This method is specific to certain memcached implementations.
	if ( method_exists( $wp_object_cache, '__remoteset' ) ) {
		$wp_object_cache->__remoteset(); // important.
	}

	$this->collect_garbage();
}