Automattic\WooCommerce\Internal\ProductFeed\Utils
MemoryManager::flush_caches
Flush the in-memory caches of the current process.
The shared persistent object cache (e.g. Redis or Memcached) is left untouched.
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() MemoryManager::flush caches code WC 11.3.0
public function flush_caches(): void {
global $wpdb, $wp_object_cache;
$wpdb->queries = array();
if ( wp_cache_supports( 'flush_runtime' ) ) {
wp_cache_flush_runtime();
}
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();
}