[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
Thu May 22 00:45:48 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 peterwilsoncc):
As a concept I like this idea for the `*-queries` groups, taking @rmccue,
@tillkruess, @sanchothefat's word on the improved efficiency for large
sites.
On the proposed implementation, I am wondeing if it would be better to
introduce new `wp_cache` functions to do the checking of the last changed
value as there are enough occurrences of the pattern in Core that it could
be worthwhile (18, based on a quick check).
Something along the lines of:
{{{#!php
<?php
wp_cache_get_query( ... $group ...) {
$query_group = "$group-queries";
$result = wp_cache_get( ... $query_group ... )
$last_changed = wp_cache_get_last_changed( $group );
if ( $result['last_changed'] !== $last_changed ) {
return $false;
}
return $result['data'];
}
wp_cache_set_query( ... $group ... ) {
$last_changed = wp_cache_get_last_changed( $group );
wp_cache_set( $key, [ 'data' => $data, 'last_chagned' => $last_changed
], $group-queries )
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59592#comment:22>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list