Changes between Initial Version and Version 34 of Ticket #59516
- Timestamp:
- 01/23/2025 10:15:18 PM (6 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #59516
-
Property
Status
changed from
new
toaccepted
-
Property
Summary
changed from
Improve cache key generation in query classes
toImprove cache key generation in the WP_Query class
- Property Owner set to pbearne
-
Property
Milestone
changed from
Future Release
to6.8
- Property Keywords has-patch changes-requested early added
-
Property
Status
changed from
-
Ticket #59516 – Description
initial v34 1 In query classes such asWP_Query, parameters like post_type enable the passing of an array of values. For instance, you can use post_type like this: ['post', 'page']. However, if a subsequent request is made with the array elements in a different order, like so: ['page', 'post'], it would lead to the generation of a different cache key, potentially causing the existing cache to be missed. Even though the cached results may be the same, this could result in a cache collision. It is advisable to reuse caches whenever possible to optimize performance.1 In WP_Query, parameters like post_type enable the passing of an array of values. For instance, you can use post_type like this: ['post', 'page']. However, if a subsequent request is made with the array elements in a different order, like so: ['page', 'post'], it would lead to the generation of a different cache key, potentially causing the existing cache to be missed. Even though the cached results may be the same, this could result in a cache collision. It is advisable to reuse caches whenever possible to optimize performance. 2 2 3 This would effect the following cache keys.3 Some sort of array sorting of the key values would mean that caches could be reused. 4 4 5 - WP_Query 5 Similar optimization can be done in other Query classes to improve cache hits on follow up tickets. 6 6 7 - WP_Term_Query 7 8 - WP_Network_Query … … 9 10 - WP_Comment_Query 10 11 11 Some sort of array sorting of the key values would mean that caches could be reused. 12 ---- 13 14 Edited 24 Jan, 2025 to focus this ticket on WP_Query per [comment:31 comments #31] thru #33.