Add support to prime refund cache in wc_order class.
Fetching refunds call is an expensive query, so priming the cache where possible could be beneficial for better performance.
This commit is contained in:
parent
b753189f64
commit
213397ffef
|
@ -1792,6 +1792,16 @@ class WC_Order extends WC_Abstract_Order {
|
|||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prime refunds cache, can be used before get_refunds to skip DB query.
|
||||
*
|
||||
* @param array $refunds array of WC_Order_Refund objects.
|
||||
*/
|
||||
public function prime_refunds_cache( $refunds ) {
|
||||
$cache_key = WC_Cache_Helper::get_cache_prefix( 'orders' ) . 'refunds' . $this->get_id();
|
||||
wp_cache_set( $cache_key, $refunds, $this->cache_group );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get order refunds.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue