Make WordPress Core

Changes between Initial Version and Version 34 of Ticket #59516


Ignore:
Timestamp:
01/23/2025 10:15:18 PM (6 months ago)
Author:
peterwilsoncc
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #59516

    • Property Status changed from new to accepted
    • Property Summary changed from Improve cache key generation in query classes to Improve cache key generation in the WP_Query class
    • Property Owner set to pbearne
    • Property Milestone changed from Future Release to 6.8
    • Property Keywords has-patch changes-requested early added
  • Ticket #59516 – Description

    initial v34  
    1 In query classes such as 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.
     1In 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.
    22
    3 This would effect the following cache keys.
     3Some sort of array sorting of the key values would mean that caches could be reused.
    44
    5 - WP_Query
     5Similar optimization can be done in other Query classes to improve cache hits on follow up tickets.
     6
    67- WP_Term_Query
    78- WP_Network_Query
     
    910- WP_Comment_Query
    1011
    11 Some sort of array sorting of the key values would mean that caches could be reused.
     12----
     13
     14Edited 24 Jan, 2025 to focus this ticket on WP_Query per [comment:31 comments #31] thru #33.