Make WordPress Core


Ignore:
Timestamp:
03/10/2023 04:27:23 PM (3 years ago)
Author:
spacedmonkey
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-query.php

    r55252 r55526  
    28092809
    28102810            $cache_key   = "comment_feed:$key:$last_changed";
    2811             $comment_ids = wp_cache_get( $cache_key, 'comment' );
     2811            $comment_ids = wp_cache_get( $cache_key, 'comment-queries' );
    28122812            if ( false === $comment_ids ) {
    28132813                $comment_ids = $wpdb->get_col( $comments_request );
    2814                 wp_cache_add( $cache_key, $comment_ids, 'comment' );
     2814                wp_cache_add( $cache_key, $comment_ids, 'comment-queries' );
    28152815            }
    28162816            _prime_comment_caches( $comment_ids, false );
     
    31663166            $cache_found = false;
    31673167            if ( null === $this->posts ) {
    3168                 $cached_results = wp_cache_get( $cache_key, 'posts', false, $cache_found );
     3168                $cached_results = wp_cache_get( $cache_key, 'post-queries', false, $cache_found );
    31693169
    31703170                if ( $cached_results ) {
     
    32213221                );
    32223222
    3223                 wp_cache_set( $cache_key, $cache_value, 'posts' );
     3223                wp_cache_set( $cache_key, $cache_value, 'post-queries' );
    32243224            }
    32253225
     
    32543254                );
    32553255
    3256                 wp_cache_set( $cache_key, $cache_value, 'posts' );
     3256                wp_cache_set( $cache_key, $cache_value, 'post-queries' );
    32573257            }
    32583258
     
    33293329            );
    33303330
    3331             wp_cache_set( $cache_key, $cache_value, 'posts' );
     3331            wp_cache_set( $cache_key, $cache_value, 'post-queries' );
    33323332        }
    33333333
     
    33683368
    33693369            $comment_cache_key = "comment_feed:$comment_key:$comment_last_changed";
    3370             $comment_ids       = wp_cache_get( $comment_cache_key, 'comment' );
     3370            $comment_ids       = wp_cache_get( $comment_cache_key, 'comment-queries' );
    33713371            if ( false === $comment_ids ) {
    33723372                $comment_ids = $wpdb->get_col( $comments_request );
    3373                 wp_cache_add( $comment_cache_key, $comment_ids, 'comment' );
     3373                wp_cache_add( $comment_cache_key, $comment_ids, 'comment-queries' );
    33743374            }
    33753375            _prime_comment_caches( $comment_ids, false );
Note: See TracChangeset for help on using the changeset viewer.