public function read_meta_data($force_read = false)
{
$this->meta_data = array();
$cache_loaded = false;
if (!$this->get_id()) {
return;
}
if (!$this->data_store) {
return;
}
if (!empty($this->cache_group)) {
$cache_key = WC_Cache_Helper::get_cache_prefix($this->cache_group) . 'object_meta_' . $this->get_id();
}
if (!$force_read) {
if (!empty($this->cache_group)) {
$cached_meta = wp_cache_get($cache_key, $this->cache_group);
if (false !== $cached_meta) {
$this->meta_data = $cached_meta;
$cache_loaded = true;
}
}
}
if (!$cache_loaded) {
$raw_meta_data = $this->data_store->read_meta($this);
if ($raw_meta_data) {
foreach ($raw_meta_data as $meta) {
$this->meta_data[] = (object) array('id' => (int) $meta->meta_id, 'key' => $meta->meta_key, 'value' => maybe_unserialize($meta->meta_value));
}
if (!empty($this->cache_group)) {
wp_cache_set($cache_key, $this->meta_data, $this->cache_group);
}
}
}
}