Automattic\WooCommerce\Internal

ScheduledSaleRun::release_caches │ private │ WC 1.0

Release the object cache entries this batch left behind.

Only this batch's entries are deleted. clean_post_cache() would invalidate wider cache state that the batch did not populate, and clean_object_term_cache() accepts a single object type while a batch can hold both products and variations.

Метод класса: ScheduledSaleRun{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

// private - только в коде основоного (родительского) класса
$result = $this->release_caches( $batch_ids, $post_types ): void;
$batch_ids(int[]) (обязательный)
Product ids in this batch.
$post_types(string[]) (обязательный)
Post types found in this batch.

Код ScheduledSaleRun::release_caches() WC 11.3.0

private function release_caches( array $batch_ids, array $post_types ): void {
	wp_cache_delete_multiple( $batch_ids, 'posts' );
	wp_cache_delete_multiple( $batch_ids, 'post_meta' );

	$taxonomies = array();
	foreach ( $post_types as $post_type ) {
		$taxonomies = array_merge( $taxonomies, get_object_taxonomies( $post_type ) );
	}

	foreach ( array_unique( $taxonomies ) as $taxonomy ) {
		wp_cache_delete_multiple( $batch_ids, "{$taxonomy}_relationships" );
	}

	// Remove entries reloaded while clearing product transients.
	if ( $this->product_cache ) {
		foreach ( $batch_ids as $product_id ) {
			$this->product_cache->remove( $product_id );
		}
	}

	if ( $this->flush_shared_groups ) {
		wp_cache_flush_group( 'products' );
		wp_cache_flush_group( 'term-queries' );
	} elseif ( wp_cache_supports( 'flush_runtime' ) ) {
		// A persistent cache keeps a request-local copy of everything it serves, so the
		// entries above that cannot be deleted by id would accumulate for the whole
		// backlog. Drop the in-memory copy only; the shared backend is untouched.
		wp_cache_flush_runtime();
	}
}