Skip to content
Snippets Groups Projects
Commit e2c1e97c authored by Erick Hitter's avatar Erick Hitter
Browse files

Simplify `get()` method's logic rather than duplicating Redis lookup calls.

Also fixes a code error introduced in 01b7283c, where the key, not the retrieved value, was passed to the `restore_value_from_redis()` method.
parent 6d489e8a
No related branches found
No related tags found
No related merge requests found
...@@ -934,18 +934,20 @@ class WP_Object_Cache { ...@@ -934,18 +934,20 @@ class WP_Object_Cache {
public function get( $key, $group = 'default', $server_key = '', $byKey = false ) { public function get( $key, $group = 'default', $server_key = '', $byKey = false ) {
$derived_key = $this->build_key( $key, $group ); $derived_key = $this->build_key( $key, $group );
if ( ! in_array( $group, $this->no_redis_groups ) ) { if ( in_array( $group, $this->no_redis_groups ) ) {
$value = $this->redis->get( $this->restore_value_from_redis( $derived_key ) );
} else {
if ( isset( $this->cache[$derived_key] ) ) { if ( isset( $this->cache[$derived_key] ) ) {
return is_object( $this->cache[$derived_key] ) ? clone $this->cache[$derived_key] : $this->cache[$derived_key]; return is_object( $this->cache[$derived_key] ) ? clone $this->cache[$derived_key] : $this->cache[$derived_key];
} elseif ( in_array( $group, $this->no_redis_groups ) ) { } elseif ( in_array( $group, $this->no_redis_groups ) ) {
return false; return false;
} else {
$value = $this->redis->get( $this->restore_value_from_redis( $derived_key ) );
} }
} }
if ( $this->redis->exists( $derived_key ) ) {
$value = $this->restore_value_from_redis( $this->redis->get( $derived_key ) );
} else {
return false;
}
$this->add_to_internal_cache( $derived_key, $value ); $this->add_to_internal_cache( $derived_key, $value );
return is_object( $value ) ? clone $value : $value; return is_object( $value ) ? clone $value : $value;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment