[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
Tue May 27 17:35:33 UTC 2025


#59592: Store last changed value in key instead of using it as a salt for query
caches
--------------------------------------+-----------------------------
 Reporter:  spacedmonkey              |       Owner:  (none)
     Type:  enhancement               |      Status:  new
 Priority:  normal                    |   Milestone:  Future Release
Component:  Cache API                 |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:  performance
--------------------------------------+-----------------------------

Comment (by tillkruess):

 Just my two cents, feel free to ignore.

 > Canonically, I think we'd want the naming convention to be with the
 cache API (ie, `wp_cache_` prefixed) rather than `wp_query` prefixed as
 we'll eventually be using this elsewhere.

 Agreed on sticking with `wp_cache_*()` prefixes for these functions.

 > Maybe it's as simple as `wp_cache_last_changed_set|get|etc` but others
 will have opinions, I am sure.

 That might be confusing with the existing
 `wp_cache_(get|set)_last_changed()`?

 > I also consider wp_cache_get_query_data and wp_cache_set_query_data for
 the naming.

 I don't mind `wp_cache_(get|set)_query()`.

 As for the signature, to accommodate multiple timestamps and an optional
 expiration, this would be my suggestion. That way the implementation can
 decide on how to handle multiple `$last_changed`.

 {{{#!php
 <?php
 function wp_cache_set_query(
     string $key,
     mixed $data,
     string $group,
     float|float[] $last_changed,
     int $expire = 0
 ) { }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59592#comment:28>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list