Make WordPress Core


Ignore:
Timestamp:
03/10/2023 04:27:23 PM (2 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-comment-query.php

    r54133 r55526  
    453453
    454454        $cache_key   = "get_comments:$key:$last_changed";
    455         $cache_value = wp_cache_get( $cache_key, 'comment' );
     455        $cache_value = wp_cache_get( $cache_key, 'comment-queries' );
    456456        if ( false === $cache_value ) {
    457457            $comment_ids = $this->get_comment_ids();
     
    464464                'found_comments' => $this->found_comments,
    465465            );
    466             wp_cache_add( $cache_key, $cache_value, 'comment' );
     466            wp_cache_add( $cache_key, $cache_value, 'comment-queries' );
    467467        } else {
    468468            $comment_ids          = $cache_value['comment_ids'];
     
    10391039            foreach ( $_parent_ids as $parent_id ) {
    10401040                $cache_key        = "get_comment_child_ids:$parent_id:$key:$last_changed";
    1041                 $parent_child_ids = wp_cache_get( $cache_key, 'comment' );
     1041                $parent_child_ids = wp_cache_get( $cache_key, 'comment-queries' );
    10421042                if ( false !== $parent_child_ids ) {
    10431043                    $child_ids = array_merge( $child_ids, $parent_child_ids );
     
    10731073                    $data[ $cache_key ] = $children;
    10741074                }
    1075                 wp_cache_set_multiple( $data, 'comment' );
     1075                wp_cache_set_multiple( $data, 'comment-queries' );
    10761076            }
    10771077
Note: See TracChangeset for help on using the changeset viewer.