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-term-query.php

    r55083 r55526  
    776776
    777777        $cache_key = $this->generate_cache_key( $args, $this->request );
    778         $cache     = wp_cache_get( $cache_key, 'terms' );
     778        $cache     = wp_cache_get( $cache_key, 'term-queries' );
    779779
    780780        if ( false !== $cache ) {
     
    802802        if ( 'count' === $_fields ) {
    803803            $count = $wpdb->get_var( $this->request ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
    804             wp_cache_set( $cache_key, $count, 'terms' );
     804            wp_cache_set( $cache_key, $count, 'term-queries' );
    805805            return $count;
    806806        }
     
    809809
    810810        if ( empty( $terms ) ) {
    811             wp_cache_add( $cache_key, array(), 'terms' );
     811            wp_cache_add( $cache_key, array(), 'term-queries' );
    812812            return array();
    813813        }
     
    889889        }
    890890
    891         wp_cache_add( $cache_key, $term_cache, 'terms' );
     891        wp_cache_add( $cache_key, $term_cache, 'term-queries' );
    892892        $this->terms = $this->format_terms( $term_objects, $_fields );
    893893
Note: See TracChangeset for help on using the changeset viewer.