[wp-trac] [WordPress Trac] #39242: Add caching to count_user_posts()

WordPress Trac noreply at wordpress.org
Fri Jul 22 19:48:13 UTC 2022


#39242: Add caching to count_user_posts()
-------------------------------------------------+-------------------------
 Reporter:  johnjamesjacoby                      |       Owner:  whyisjake
     Type:  enhancement                          |      Status:  accepted
 Priority:  normal                               |   Milestone:  Future
                                                 |  Release
Component:  Users                                |     Version:  3.0
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch dev-feedback needs-unit-   |     Focuses:  rest-api,
  tests needs-testing                            |  performance
-------------------------------------------------+-------------------------

Comment (by johnregan3):

 The reason unit test # 2 above is failing is because a post is being
 created and the value returned by count_user_posts() is returning the
 cached (former) value.

 Looks like this will need an action hooked into (probably) 'save_post'
 that clears this cache.  However, as the cache key is dependent upon the
 post type(s) are requested, it's trickier to guess the precise cache key
 we need to delete when a post is saved.

 I'd love some input on the best way to approach this.

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


More information about the wp-trac mailing list