_prime_post_caches()
Adds any posts from the given IDs to the cache that do not already exist in cache
This is an internal function for using it by WP core itself. It's not recommended to use this function in your code.
1 time — 0.012805 sec (extremely slow) | 50000 times — 0.78 sec (very fast)
No Hooks.
Return
null
. Nothing.
Usage
_prime_post_caches( $ids, $update_term_cache, $update_meta_cache );
- $ids(array) (required)
- ID list.
- $update_term_cache(true|false)
- Whether to update the term cache.
Default: true - $update_meta_cache(true|false)
- Whether to update the meta cache.
Default: true
Notes
- See: update_post_caches()
- Global. wpdb. $wpdb WordPress database abstraction object.
Changelog
Since 3.4.0 | Introduced. |
Code of _prime_post_caches() prime post caches WP 5.9.3
function _prime_post_caches( $ids, $update_term_cache = true, $update_meta_cache = true ) { global $wpdb; $non_cached_ids = _get_non_cached_ids( $ids, 'posts' ); if ( ! empty( $non_cached_ids ) ) { $fresh_posts = $wpdb->get_results( sprintf( "SELECT $wpdb->posts.* FROM $wpdb->posts WHERE ID IN (%s)", implode( ',', $non_cached_ids ) ) ); update_post_caches( $fresh_posts, 'any', $update_term_cache, $update_meta_cache ); } }