Automattic\WooCommerce\Caches
ProductCountCacheService::prime_cache_if_cold
Primes the product count cache for a given post type when it is cold.
Method of the class: ProductCountCacheService{}
No Hooks.
Returns
void. Nothing (null).
Usage
$ProductCountCacheService = new ProductCountCacheService(); $ProductCountCacheService->prime_cache_if_cold( $product_type ): void;
- $product_type(string)
- The product post type.
Default:'product'
ProductCountCacheService::prime_cache_if_cold() ProductCountCacheService::prime cache if cold code WC 11.1.2
public function prime_cache_if_cold( string $product_type = 'product' ): void {
// 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->product_count_cache->get( $product_type ) ) {
$this->product_count_cache->flush( $product_type );
wc_get_container()->get( ProductUtil::class )->get_counts_for_type( $product_type );
}
}