Make WordPress Core

Changes between Version 2 and Version 3 of Ticket #66098


Ignore:
Timestamp:
09/14/2026 06:18:42 PM (2 months ago)
Author:
westonruter
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #66098 – Description

    v2 v3  
    55For a large publisher, an exact real-time count in the admin dashboard is not important as long as they are able to publish without the list screen taking several seconds to load.  We can happily trade a little count accuracy for performance.
    66
    7 We can run the aggregate in the background using Action Scheduler and store
    8 the result in a durable store (an option). But to make `wp_count_posts()` actually
    9 return that value and skip its query, we have to fill core's object cache by hand. On every request, we `wp_cache_set()` the stored counts under the key
    10 returned by internal `_count_posts_cache_key()` function, so core's `wp_count_posts()` hits the cache.
    11 
     7We can run the aggregate in the background using Action Scheduler and store the result in a durable store (an option). But to make `wp_count_posts()` actually return that value and skip its query, we have to fill core's object cache by hand. On every request, we `wp_cache_set()` the stored counts under the key returned by internal `_count_posts_cache_key()` function, so core's `wp_count_posts()` hits the cache.
    128
    139With a `pre_wp_count_posts` filter, `wp_count_posts()` could serve the pre-computed value (for whoever wants to trade off accuracy for performance) and skip the main query entirely.