mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Build/Test Tools: Fix issue with add method in object-cache.php.
In the object-cache.php file used for unit tests, the add method did not work as expected. Other object cache plugins and core, have a check to see if the key exists in memory before writing it. Without this check, it used to write unnecessarily to the cache. Props spacedmonkey, SergeyBiryukov. Fixes #57963. git-svn-id: https://develop.svn.wordpress.org/trunk@55577 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -977,21 +977,22 @@ class WP_Object_Cache {
|
||||
}
|
||||
|
||||
$derived_key = $this->buildKey( $key, $group );
|
||||
$expiration = $this->sanitize_expiration( $expiration );
|
||||
|
||||
// Add does not set the value if the key exists; mimic that here.
|
||||
if ( isset( $this->cache[ $derived_key ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If group is a non-Memcached group, save to runtime cache, not Memcached.
|
||||
if ( in_array( $group, $this->no_mc_groups, true ) ) {
|
||||
|
||||
// Add does not set the value if the key exists; mimic that here.
|
||||
if ( isset( $this->cache[ $derived_key ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->add_to_internal_cache( $derived_key, $value );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$expiration = $this->sanitize_expiration( $expiration );
|
||||
|
||||
// Save to Memcached.
|
||||
if ( $by_key ) {
|
||||
$result = $this->m->addByKey( $server_key, $derived_key, $value, $expiration );
|
||||
|
||||
Reference in New Issue
Block a user