Use transients to cache products/variations stats results (https://github.com/woocommerce/woocommerce-admin/pull/7067)

* Use transients to cache products/variations stats results

* Add readme entry

* Fix readme

Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com>
This commit is contained in:
Manos Psychogyiopoulos 2021-07-02 12:38:35 +03:00 committed by GitHub
parent 88934afef4
commit 2bda6e2e26
3 changed files with 18 additions and 3 deletions

View File

@ -101,6 +101,7 @@ Release and roadmap notes are available on the [WooCommerce Developers Blog](htt
- Fix: Report export filtering bug. #7165
- Fix: Use tab char for the CSV injection prevention. #7154
- Fix: Fix and refactor explat polling to use setTimeout #7274
- Fix: Cache product/variation revenue query results. #7067
- Tweak: Remove performance indicators when Analytics Flag disabled #7234
- Tweak: Revert Card component removal #7167
- Tweak: Repurpose disable wc-admin filter to remove optional features #7232
@ -183,7 +184,7 @@ Release and roadmap notes are available on the [WooCommerce Developers Blog](htt
- Fix: Multiple preload tag output bug. #6998
- Fix: Call existing filters for leaderboards in analytics. #6626
- Fix: Set target to blank for the external links #6999
- Fix style regression with the Chart header. #7002
- Fix: Style regression with the Chart header. #7002
- Fix styling of the advanced filter operator selection. #7005
- Fix: Deprecated warnings from select control @wordpress/data-controls. #7007
- Fix: Bug with Orders Report coupon exclusion filter. #7021

View File

@ -33,6 +33,13 @@ class DataStore extends ProductsDataStore implements DataStoreInterface {
'variations_count' => 'intval',
);
/**
* Cache identifier.
*
* @var string
*/
protected $cache_key = 'products_stats';
/**
* Data store context used to pass to filters.
*
@ -215,7 +222,7 @@ class DataStore extends ProductsDataStore implements DataStoreInterface {
$segmenter->add_intervals_segments( $data, $intervals_query, $table_name );
$this->create_interval_subtotals( $data->intervals );
wp_cache_set( $cache_key, $data, $this->cache_group );
$this->set_cached_data( $cache_key, $data );
}
return $data;

View File

@ -29,6 +29,13 @@ class DataStore extends VariationsDataStore implements DataStoreInterface {
'variations_count' => 'intval',
);
/**
* Cache identifier.
*
* @var string
*/
protected $cache_key = 'variations_stats';
/**
* Data store context used to pass to filters.
*
@ -242,7 +249,7 @@ class DataStore extends VariationsDataStore implements DataStoreInterface {
$segmenter->add_intervals_segments( $data, $intervals_query, $table_name );
$this->create_interval_subtotals( $data->intervals );
wp_cache_set( $cache_key, $data, $this->cache_group );
$this->set_cached_data( $cache_key, $data );
}
return $data;