[wp-trac] [WordPress Trac] #59592: Store last changed value in key instead of using it as a salt for query caches
WordPress Trac
noreply at wordpress.org
Sun Aug 31 21:48:16 UTC 2025
#59592: Store last changed value in key instead of using it as a salt for query
caches
-------------------------------------------------+-------------------------
Reporter: spacedmonkey | Owner:
| spacedmonkey
Type: enhancement | Status: closed
Priority: normal | Milestone: 6.9
Component: Cache API | Version:
Severity: normal | Resolution: fixed
Keywords: has-patch has-unit-tests needs-dev- | Focuses:
note | performance
-------------------------------------------------+-------------------------
Changes (by spacedmonkey):
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"60697" 60697]:
{{{
Caching API: Use consistent cache keys for query groups.
Query-based caches are now improved by reusing cache keys. Previously,
cache keys for query caches were generated using the `last_changed` value
as part of the key. This meant that whenever `last_changed` was updated,
all the previously cached values for the group became unreachable.
The new approach allows WordPress to replace previously cached results
that are known to be stale. The previous approach relied on the object
cache backend evicting stale keys which is done at various levels of
efficiency.
To address this, the following new helper functions have been introduced:
* wp_cache_get_salted
* wp_cache_set_salted
* wp_cache_get_multiple_salted
* wp_cache_set_multiple_salted
These functions provide a consistent way to get/set query caches. Instead
of using the last_changed value as part of the cache key, it is now stored
inside the cache value as a "salt". This allows cache keys to be reused,
with values updated in place rather than relying on eviction of outdated
entries.
Props spacedmonkey, peterwilsoncc, flixos90, sanchothefat, tillkruess,
rmccue, mukesh27, adamsilverstein, owi, nickchomey.
Fixes #59592.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59592#comment:54>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list