[wp-trac] [WordPress Trac] #57625: WP_Query cache memory leak

WordPress Trac noreply at wordpress.org
Wed Feb 8 17:22:34 UTC 2023


#57625: WP_Query cache memory leak
--------------------------+------------------------------
 Reporter:  owi           |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Cache API     |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  performance
--------------------------+------------------------------

Comment (by tillkruess):

 Replying to [comment:10 spacedmonkey]:
 > How about changing the cache group that query are stored in?
 >
 > {{{#!php
 > $cached_results = wp_cache_get( $cache_key, 'post-query', false,
 $cache_found );
 > }}}

 The issue with grouping the `comment-queries` and `post-queries` would be
 that we'd invalidate other queries that don't need to be invalidated.

 {{{#!php
 // `comment-queries` group
 "get_comments:$key:$last_changed"
 "get_comment_child_ids:$parent_id:$key:$last_changed"

 // `post-queries` group
 "get_page_by_path:$hash:$last_changed"
 "adjacent_post:$key:$last_changed"
 "wp_get_archives:$key:$last_changed"
 }}}

 I wonder if it would be good to have a dedicated helper for "query"
 caching, since it's quite repetitive. We do have ~20 occurrences.

 {{{#!php
 function wp_cache_query( $type, $key, $last_changed, $group );

 wp_cache_query( 'get_objects_in_term', md5( $sql ), $last_changed,
 'terms' );
 }}}

 That way object cache implementation knows:
 1. it's a query
 2. the query's group
 3. the group's last-changed timestamp

 And they can handle expiration, invalidation and storage however they
 like.

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


More information about the wp-trac mailing list