mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-15 22:30:25 +00:00
Cache API: Introduce new queries cache groups.
Give developers more control over how query caches are handled within an object caches. Now all caches that cache the result of a query, are cached in a group that is suffixed with -queries. Developers can use these groups, to add custom cache invalidation rules or to make them none persistent. Props spacedmonkey, owi, tillkruess, skithund, peterwilsoncc, flixos90, sergeybiryukov, mukesh27. Fixes #57625. git-svn-id: https://develop.svn.wordpress.org/trunk@55526 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -2808,10 +2808,10 @@ class WP_Query {
|
||||
$last_changed = wp_cache_get_last_changed( 'comment' ) . ':' . wp_cache_get_last_changed( 'posts' );
|
||||
|
||||
$cache_key = "comment_feed:$key:$last_changed";
|
||||
$comment_ids = wp_cache_get( $cache_key, 'comment' );
|
||||
$comment_ids = wp_cache_get( $cache_key, 'comment-queries' );
|
||||
if ( false === $comment_ids ) {
|
||||
$comment_ids = $wpdb->get_col( $comments_request );
|
||||
wp_cache_add( $cache_key, $comment_ids, 'comment' );
|
||||
wp_cache_add( $cache_key, $comment_ids, 'comment-queries' );
|
||||
}
|
||||
_prime_comment_caches( $comment_ids, false );
|
||||
|
||||
@@ -3165,7 +3165,7 @@ class WP_Query {
|
||||
|
||||
$cache_found = false;
|
||||
if ( null === $this->posts ) {
|
||||
$cached_results = wp_cache_get( $cache_key, 'posts', false, $cache_found );
|
||||
$cached_results = wp_cache_get( $cache_key, 'post-queries', false, $cache_found );
|
||||
|
||||
if ( $cached_results ) {
|
||||
if ( 'ids' === $q['fields'] ) {
|
||||
@@ -3220,7 +3220,7 @@ class WP_Query {
|
||||
'max_num_pages' => $this->max_num_pages,
|
||||
);
|
||||
|
||||
wp_cache_set( $cache_key, $cache_value, 'posts' );
|
||||
wp_cache_set( $cache_key, $cache_value, 'post-queries' );
|
||||
}
|
||||
|
||||
return $this->posts;
|
||||
@@ -3253,7 +3253,7 @@ class WP_Query {
|
||||
'max_num_pages' => $this->max_num_pages,
|
||||
);
|
||||
|
||||
wp_cache_set( $cache_key, $cache_value, 'posts' );
|
||||
wp_cache_set( $cache_key, $cache_value, 'post-queries' );
|
||||
}
|
||||
|
||||
return $post_parents;
|
||||
@@ -3328,7 +3328,7 @@ class WP_Query {
|
||||
'max_num_pages' => $this->max_num_pages,
|
||||
);
|
||||
|
||||
wp_cache_set( $cache_key, $cache_value, 'posts' );
|
||||
wp_cache_set( $cache_key, $cache_value, 'post-queries' );
|
||||
}
|
||||
|
||||
if ( ! $q['suppress_filters'] ) {
|
||||
@@ -3367,10 +3367,10 @@ class WP_Query {
|
||||
$comment_last_changed = wp_cache_get_last_changed( 'comment' );
|
||||
|
||||
$comment_cache_key = "comment_feed:$comment_key:$comment_last_changed";
|
||||
$comment_ids = wp_cache_get( $comment_cache_key, 'comment' );
|
||||
$comment_ids = wp_cache_get( $comment_cache_key, 'comment-queries' );
|
||||
if ( false === $comment_ids ) {
|
||||
$comment_ids = $wpdb->get_col( $comments_request );
|
||||
wp_cache_add( $comment_cache_key, $comment_ids, 'comment' );
|
||||
wp_cache_add( $comment_cache_key, $comment_ids, 'comment-queries' );
|
||||
}
|
||||
_prime_comment_caches( $comment_ids, false );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user