| 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 | | |
| | 7 | We 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. |