Automattic\WooCommerce\Admin\API\Reports
DataStore::get_cache_key
Returns string to be used as cache key for the data.
Method of the class: DataStore{}
No Hooks.
Returns
String.
Usage
// protected - for code of main (parent) or child class $result = $this->get_cache_key( $params );
- $params(array) (required)
- Query parameters.
DataStore::get_cache_key() DataStore::get cache key code WC 10.8.1
protected function get_cache_key( $params ) {
if ( isset( $params['force_cache_refresh'] ) ) {
if ( true === $params['force_cache_refresh'] ) {
$this->force_cache_refresh = true;
}
// We don't want this param in the key.
unset( $params['force_cache_refresh'] );
}
if ( true === $this->debug_cache ) {
$this->debug_cache_data['query_args'] = $params;
}
// Normalize the $params to reduce cache misses.
$params = array_filter(
$params,
function ( $param ) {
return ! empty( $param );
}
);
ksort( $params );
return implode(
'_',
array(
'wc_report',
$this->cache_key,
md5( wp_json_encode( $params ) ),
)
);
}