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

    r54962 r55526  
    11551155    $last_changed = wp_cache_get_last_changed( 'posts' );
    11561156    $cache_key    = "find_post_by_old_slug:$key:$last_changed";
    1157     $cache        = wp_cache_get( $cache_key, 'posts' );
     1157    $cache        = wp_cache_get( $cache_key, 'post-queries' );
    11581158    if ( false !== $cache ) {
    11591159        $id = $cache;
    11601160    } else {
    11611161        $id = (int) $wpdb->get_var( $query );
    1162         wp_cache_set( $cache_key, $id, 'posts' );
     1162        wp_cache_set( $cache_key, $id, 'post-queries' );
    11631163    }
    11641164
     
    11981198        $last_changed = wp_cache_get_last_changed( 'posts' );
    11991199        $cache_key    = "find_post_by_old_date:$key:$last_changed";
    1200         $cache        = wp_cache_get( $cache_key, 'posts' );
     1200        $cache        = wp_cache_get( $cache_key, 'post-queries' );
    12011201        if ( false !== $cache ) {
    12021202            $id = $cache;
     
    12071207                $id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts, $wpdb->postmeta AS pm_slug, $wpdb->postmeta AS pm_date WHERE ID = pm_slug.post_id AND ID = pm_date.post_id AND post_type = %s AND pm_slug.meta_key = '_wp_old_slug' AND pm_slug.meta_value = %s AND pm_date.meta_key = '_wp_old_date'" . $date_query, $post_type, get_query_var( 'name' ) ) );
    12081208            }
    1209             wp_cache_set( $cache_key, $id, 'posts' );
     1209            wp_cache_set( $cache_key, $id, 'post-queries' );
    12101210        }
    12111211    }
Note: See TracChangeset for help on using the changeset viewer.