From c4c8edee5fad930604c7d6f018e77a2b39eb3a02 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 21 Mar 2017 23:37:38 +0000 Subject: [PATCH] Remove order and product factory cache --- includes/abstracts/abstract-wc-data.php | 1 - includes/class-wc-order-factory.php | 20 ++----------------- includes/class-wc-product-factory.php | 10 +--------- .../class-wc-product-data-store-cpt.php | 1 - 4 files changed, 3 insertions(+), 29 deletions(-) diff --git a/includes/abstracts/abstract-wc-data.php b/includes/abstracts/abstract-wc-data.php index ea447f7396a..13e532e6127 100644 --- a/includes/abstracts/abstract-wc-data.php +++ b/includes/abstracts/abstract-wc-data.php @@ -469,7 +469,6 @@ 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 ); } } diff --git a/includes/class-wc-order-factory.php b/includes/class-wc-order-factory.php index ba5edc75e35..f465ee8e800 100644 --- a/includes/class-wc-order-factory.php +++ b/includes/class-wc-order-factory.php @@ -44,15 +44,7 @@ class WC_Order_Factory { } try { - // Try to get from cache, otherwise create a new object, - $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; + return new $classname( $order_id ); } catch ( Exception $e ) { return false; } @@ -107,15 +99,7 @@ class WC_Order_Factory { if ( $classname && class_exists( $classname ) ) { try { - // Try to get from cache, otherwise create a new object, - $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; + return new $classname( $id ); } catch ( Exception $e ) { return false; } diff --git a/includes/class-wc-product-factory.php b/includes/class-wc-product-factory.php index 9f1c1ae8c51..8626900b0f0 100644 --- a/includes/class-wc-product-factory.php +++ b/includes/class-wc-product-factory.php @@ -43,15 +43,7 @@ class WC_Product_Factory { $classname = $this->get_product_classname( $product_id, $product_type ); try { - // Try to get from cache, otherwise create a new object, - $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; + return new $classname( $product_id, $deprecated ); } catch ( Exception $e ) { return false; } diff --git a/includes/data-stores/class-wc-product-data-store-cpt.php b/includes/data-stores/class-wc-product-data-store-cpt.php index 053ab792daf..c2a828f4aac 100644 --- a/includes/data-stores/class-wc-product-data-store-cpt.php +++ b/includes/data-stores/class-wc-product-data-store-cpt.php @@ -695,7 +695,6 @@ 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( 'object-' . $product->get_id(), 'products' ); } /*