Automattic\WooCommerce\Admin\API\Reports

DataStore::get_cached_data()protectedWC 1.0

Wrapper around Cache::get().

Method of the class: DataStore{}

No Hooks.

Return

Mixed.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_cached_data( $cache_key );
$cache_key(string) (required)
Cache key.

DataStore::get_cached_data() code WC 8.7.0

protected function get_cached_data( $cache_key ) {
	if ( true === $this->debug_cache ) {
		$this->debug_cache_data['should_use_cache']    = $this->should_use_cache();
		$this->debug_cache_data['force_cache_refresh'] = $this->force_cache_refresh;
		$this->debug_cache_data['cache_hit']           = false;
	}

	if ( $this->should_use_cache() && false === $this->force_cache_refresh ) {
		$cached_data = Cache::get( $cache_key );

		$cache_hit = false !== $cached_data;
		if ( true === $this->debug_cache ) {
			$this->debug_cache_data['cache_hit'] = $cache_hit;
		}

		return $cached_data;
	}

	// Cached item has now functionally been refreshed. Reset the option.
	$this->force_cache_refresh = false;

	return false;
}