Merge pull request #13443 from woocommerce/cache-groups

Standardize cache group names
This commit is contained in:
Mike Jolley 2017-03-03 10:44:34 +00:00 committed by GitHub
commit 8440083fef
7 changed files with 10 additions and 9 deletions

View File

@ -435,6 +435,7 @@ abstract class WC_Data {
if ( ! empty( $this->cache_group ) ) {
WC_Cache_Helper::incr_cache_prefix( $this->cache_group );
wp_cache_delete( 'object-' . $this->get_id(), $this->cache_group );
}
}

View File

@ -67,7 +67,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
* A group must be set to to enable caching.
* @var string
*/
protected $cache_group = 'order';
protected $cache_group = 'orders';
/**
* Which data store to load.

View File

@ -45,11 +45,11 @@ class WC_Order_Factory {
try {
// 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' ) ) {
$order = new $classname( $order_id );
wp_cache_set( 'order-' . $order_id, $order, 'orders' );
wp_cache_set( 'object-' . $order_id, $order, 'orders' );
}
return $order;
@ -104,11 +104,11 @@ class WC_Order_Factory {
if ( $classname ) {
try {
// 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' ) ) {
$item = new $classname( $id );
wp_cache_set( 'order-item-' . $id, $item, 'order-items' );
wp_cache_set( 'object-' . $id, $item, 'order-items' );
}
return $item;

View File

@ -37,7 +37,7 @@ class WC_Order_Item extends WC_Data implements ArrayAccess {
* A group must be set to to enable caching.
* @var string
*/
protected $cache_group = 'order_itemmeta';
protected $cache_group = 'order-items';
/**
* Meta type. This should match up with

View File

@ -272,7 +272,7 @@ abstract class Abstract_WC_Order_Data_Store_CPT extends WC_Data_Store_WP impleme
protected function clear_caches( &$order ) {
clean_post_cache( $order->get_id() );
wc_delete_shop_order_transients( $order );
wp_cache_delete( 'order-' . $order->get_id(), 'orders' );
wp_cache_delete( 'object-' . $order->get_id(), 'orders' );
}
/**

View File

@ -128,6 +128,6 @@ abstract class Abstract_WC_Order_Item_Type_Data_Store extends WC_Data_Store_WP i
* Clear meta cachce.
*/
public function clear_cache( &$item ) {
wp_cache_delete( 'order-item-' . $item->get_id(), 'order-items' );
wp_cache_delete( 'object-' . $item->get_id(), 'order-items' );
}
}

View File

@ -684,7 +684,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
*/
protected function clear_caches( &$product ) {
wc_delete_product_transients( $product->get_id() );
wp_cache_delete( 'product-' . $product->get_id(), 'products' );
wp_cache_delete( 'object-' . $product->get_id(), 'products' );
}
/*