[wp-trac] [WordPress Trac] #39242: Add caching to count_user_posts()
WordPress Trac
noreply at wordpress.org
Wed Aug 19 18:41:27 UTC 2020
#39242: Add caching to count_user_posts()
------------------------------------+------------------------------------
Reporter: johnjamesjacoby | Owner: whyisjake
Type: enhancement | Status: accepted
Priority: normal | Milestone: 5.6
Component: Users | Version: 3.0
Severity: normal | Resolution:
Keywords: has-patch dev-feedback | Focuses: rest-api, performance
------------------------------------+------------------------------------
Changes (by desrosj):
* version: 5.5 => 3.0
Comment:
Changing the version to 3.0 because that's the first version the function
existed without caching.
Looking at [attachment:"39242.diff"], it doesn't take into account the
`$post_type` or `$public_only` parameters.
Also, looking at other cached values in core, it seems that not specifying
an expiration in favor of invalidating the cache when appropriate is
preferred. In this case, when a post is updated (published/unpublished, or
visibility is changed).
[attachment:"39242.2.diff"] adds the post type to the cache key, and
introduces an additional group for when `$public_only` is `true`.
I toyed around with where to invalidate caches for a while. Somewhere
inside `clean_user_cache()` feels like the right spot. But there is no way
to pass the two additional parameters. Inside `wp_insert_post()` should be
more feasible.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39242#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list