Standardize cache group names
This commit is contained in:
parent
c81dd47eb8
commit
1a8737fdeb
|
@ -435,6 +435,7 @@ abstract class WC_Data {
|
||||||
|
|
||||||
if ( ! empty( $this->cache_group ) ) {
|
if ( ! empty( $this->cache_group ) ) {
|
||||||
WC_Cache_Helper::incr_cache_prefix( $this->cache_group );
|
WC_Cache_Helper::incr_cache_prefix( $this->cache_group );
|
||||||
|
wp_cache_delete( 'object-' . $this->get_id(), $this->cache_group );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
||||||
* A group must be set to to enable caching.
|
* A group must be set to to enable caching.
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $cache_group = 'order';
|
protected $cache_group = 'orders';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Which data store to load.
|
* Which data store to load.
|
||||||
|
|
|
@ -45,11 +45,11 @@ class WC_Order_Factory {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Try to get from cache, otherwise create a new object,
|
// Try to get from cache, otherwise create a new object,
|
||||||
$order = wp_cache_get( 'order-' . $order_id, 'orders' );
|
$order = wp_cache_get( 'object-' . $order_id, 'orders' );
|
||||||
|
|
||||||
if ( ! is_a( $order, 'WC_Order' ) ) {
|
if ( ! is_a( $order, 'WC_Order' ) ) {
|
||||||
$order = new $classname( $order_id );
|
$order = new $classname( $order_id );
|
||||||
wp_cache_set( 'order-' . $order_id, $order, 'orders' );
|
wp_cache_set( 'object-' . $order_id, $order, 'orders' );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $order;
|
return $order;
|
||||||
|
@ -104,11 +104,11 @@ class WC_Order_Factory {
|
||||||
if ( $classname ) {
|
if ( $classname ) {
|
||||||
try {
|
try {
|
||||||
// Try to get from cache, otherwise create a new object,
|
// Try to get from cache, otherwise create a new object,
|
||||||
$item = wp_cache_get( 'order-item-' . $id, 'order-items' );
|
$item = wp_cache_get( 'object-' . $id, 'order-items' );
|
||||||
|
|
||||||
if ( ! is_a( $item, 'WC_Order_Item' ) ) {
|
if ( ! is_a( $item, 'WC_Order_Item' ) ) {
|
||||||
$item = new $classname( $id );
|
$item = new $classname( $id );
|
||||||
wp_cache_set( 'order-item-' . $id, $item, 'order-items' );
|
wp_cache_set( 'object-' . $id, $item, 'order-items' );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $item;
|
return $item;
|
||||||
|
|
|
@ -37,7 +37,7 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
|
||||||
* A group must be set to to enable caching.
|
* A group must be set to to enable caching.
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $cache_group = 'order_itemmeta';
|
protected $cache_group = 'order-items';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Meta type. This should match up with
|
* Meta type. This should match up with
|
||||||
|
|
|
@ -258,7 +258,7 @@ abstract class Abstract_WC_Order_Data_Store_CPT extends WC_Data_Store_WP impleme
|
||||||
protected function clear_caches( &$order ) {
|
protected function clear_caches( &$order ) {
|
||||||
clean_post_cache( $order->get_id() );
|
clean_post_cache( $order->get_id() );
|
||||||
wc_delete_shop_order_transients( $order );
|
wc_delete_shop_order_transients( $order );
|
||||||
wp_cache_delete( 'order-' . $order->get_id(), 'orders' );
|
wp_cache_delete( 'object-' . $order->get_id(), 'orders' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -128,6 +128,6 @@ abstract class Abstract_WC_Order_Item_Type_Data_Store extends WC_Data_Store_WP i
|
||||||
* Clear meta cachce.
|
* Clear meta cachce.
|
||||||
*/
|
*/
|
||||||
public function clear_cache( &$item ) {
|
public function clear_cache( &$item ) {
|
||||||
wp_cache_delete( 'order-item-' . $item->get_id(), 'order-items' );
|
wp_cache_delete( 'object-' . $item->get_id(), 'order-items' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -680,7 +680,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
|
||||||
*/
|
*/
|
||||||
protected function clear_caches( &$product ) {
|
protected function clear_caches( &$product ) {
|
||||||
wc_delete_product_transients( $product->get_id() );
|
wc_delete_product_transients( $product->get_id() );
|
||||||
wp_cache_delete( 'product-' . $product->get_id(), 'products' );
|
wp_cache_delete( 'object-' . $product->get_id(), 'products' );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue