[wp-trac] [WordPress Trac] #63045: Add caching to `count_many_users_posts()`

WordPress Trac noreply at wordpress.org
Sat Jun 28 05:31:25 UTC 2025


#63045: Add caching to `count_many_users_posts()`
--------------------------------------+--------------------------
 Reporter:  flixos90                  |       Owner:  (none)
     Type:  enhancement               |      Status:  new
 Priority:  normal                    |   Milestone:  6.9
Component:  Users                     |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:  performance
--------------------------------------+--------------------------

Comment (by rollybueno):

 I'm not a fan of md5() the query statement so I pushed a new patch version
 in https://github.com/WordPress/wordpress-develop/pull/9106/ that:
 - More transparent cache keys – avoids md5() and instead uses readable,
 parameter-based keys (user IDs, post type, `$public_only`), which makes it
 easier to debug and trace.
 - Proper separation of cached data – different input combinations get
 unique keys, reducing the risk of stale or incorrect cache results.
 - Better cache grouping – avoids using a static group, so it's safer and
 more aligned with how the query behaves.
 - Easier to maintain or extend – the logic is clearer and more flexible
 for future changes.

 Overall, it's a more accurate, debuggable, and scalable approach to
 caching in `count_many_users_posts()`.

 My questions:
 1. ❓ Should we have the OC an expiration? If yes, how long? I have set to
 1 hour but it's open for discussions.
 2. ❓ We probably need cache clearing function, but on what actions it
 should hook into?

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


More information about the wp-trac mailing list