Remove order and product factory cache
This commit is contained in:
parent
795e6871c0
commit
c4c8edee5f
|
@ -469,7 +469,6 @@ 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 );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,15 +44,7 @@ class WC_Order_Factory {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Try to get from cache, otherwise create a new object,
|
return new $classname( $order_id );
|
||||||
$order = wp_cache_get( 'object-' . $order_id, 'orders' );
|
|
||||||
|
|
||||||
if ( ! is_a( $order, 'WC_Order' ) ) {
|
|
||||||
$order = new $classname( $order_id );
|
|
||||||
wp_cache_set( 'object-' . $order_id, $order, 'orders' );
|
|
||||||
}
|
|
||||||
|
|
||||||
return $order;
|
|
||||||
} catch ( Exception $e ) {
|
} catch ( Exception $e ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -107,15 +99,7 @@ class WC_Order_Factory {
|
||||||
|
|
||||||
if ( $classname && class_exists( $classname ) ) {
|
if ( $classname && class_exists( $classname ) ) {
|
||||||
try {
|
try {
|
||||||
// Try to get from cache, otherwise create a new object,
|
return new $classname( $id );
|
||||||
$item = wp_cache_get( 'object-' . $id, 'order-items' );
|
|
||||||
|
|
||||||
if ( ! is_a( $item, 'WC_Order_Item' ) ) {
|
|
||||||
$item = new $classname( $id );
|
|
||||||
wp_cache_set( 'object-' . $id, $item, 'order-items' );
|
|
||||||
}
|
|
||||||
|
|
||||||
return $item;
|
|
||||||
} catch ( Exception $e ) {
|
} catch ( Exception $e ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,15 +43,7 @@ class WC_Product_Factory {
|
||||||
$classname = $this->get_product_classname( $product_id, $product_type );
|
$classname = $this->get_product_classname( $product_id, $product_type );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Try to get from cache, otherwise create a new object,
|
return new $classname( $product_id, $deprecated );
|
||||||
$product = wp_cache_get( 'product-' . $product_id, 'products' );
|
|
||||||
|
|
||||||
if ( ! is_a( $product, 'WC_Product' ) ) {
|
|
||||||
$product = new $classname( $product_id, $deprecated );
|
|
||||||
wp_cache_set( 'product-' . $product_id, $product, 'products' );
|
|
||||||
}
|
|
||||||
|
|
||||||
return $product;
|
|
||||||
} catch ( Exception $e ) {
|
} catch ( Exception $e ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -695,7 +695,6 @@ 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( 'object-' . $product->get_id(), 'products' );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue