Automattic\WooCommerce\Blocks\BlockTypes

AbstractProductGrid::get_non_cached_ids()protectedWC 1.0

Retrieve IDs that are not already present in the cache.

Based on WordPress function: _get_non_cached_ids

Method of the class: AbstractProductGrid{}

No Hooks.

Return

Int[]. Array of IDs not present in the cache.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_non_cached_ids( $product_ids, $cache_key );
$product_ids(int[]) (required)
Array of IDs.
$cache_key(string) (required)
The cache bucket to check against.

AbstractProductGrid::get_non_cached_ids() code WC 9.4.2

protected function get_non_cached_ids( $product_ids, $cache_key ) {
	$non_cached_ids = array();
	$cache_values   = wp_cache_get_multiple( $product_ids, $cache_key );

	foreach ( $cache_values as $id => $value ) {
		if ( ! $value ) {
			$non_cached_ids[] = (int) $id;
		}
	}

	return $non_cached_ids;
}