Add id cache group to invalidate by ID

This commit is contained in:
Mike Jolley 2017-05-30 14:37:29 +01:00
parent f6b9c57b5b
commit 2366a036e3
1 changed files with 4 additions and 3 deletions

View File

@ -435,7 +435,8 @@ abstract class WC_Data {
}
if ( ! empty( $this->cache_group ) ) {
$cache_key = WC_Cache_Helper::get_cache_prefix( $this->cache_group ) . 'object_meta_' . $this->get_id();
// Prefix by group allows invalidation by group until https://core.trac.wordpress.org/ticket/4476 is implemented.
$cache_key = WC_Cache_Helper::get_cache_prefix( $this->cache_group ) . WC_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
}
if ( ! $force_read ) {
@ -483,9 +484,9 @@ abstract class WC_Data {
$this->data_store->update_meta( $this, $meta );
}
}
if ( ! empty( $this->cache_group ) ) {
WC_Cache_Helper::incr_cache_prefix( $this->cache_group );
$cache_key = WC_Cache_Helper::get_cache_prefix( $this->cache_group ) . WC_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
wp_cache_delete( $cache_key, $this->cache_group );
}
}