Automattic\WooCommerce\Caches
OrderCountCacheService::prime_cache_if_cold
Keeps the cache warm for a specific order type to maintain admin performance, especially after extended periods of inactivity or when the cache has been cleared.
Method of the class: OrderCountCacheService{}
No Hooks.
Returns
null. Nothing (null).
Usage
$OrderCountCacheService = new OrderCountCacheService(); $OrderCountCacheService->prime_cache_if_cold( $order_type );
- $order_type(string) (required)
- The order type.
Changelog
| Since 10.7.0 | Introduced. |
OrderCountCacheService::prime_cache_if_cold() OrderCountCacheService::prime cache if cold code WC 10.9.1
public function prime_cache_if_cold( $order_type ) {
// Cache warm-up is only effective when an object cache plugin is active, and the cache entry is missing.
if ( wp_using_ext_object_cache() && null === $this->order_count_cache->get( $order_type ) ) {
$this->order_count_cache->flush( $order_type );
OrderUtil::get_count_for_type( $order_type );
}
}