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

    r55437 r55526  
    56765676    $hash      = md5( $page_path . serialize( $post_type ) );
    56775677    $cache_key = "get_page_by_path:$hash:$last_changed";
    5678     $cached    = wp_cache_get( $cache_key, 'posts' );
     5678    $cached    = wp_cache_get( $cache_key, 'post-queries' );
    56795679    if ( false !== $cached ) {
    56805680        // Special case: '0' is a bad `$page_path`.
     
    57435743
    57445744    // We cache misses as well as hits.
    5745     wp_cache_set( $cache_key, $foundid, 'posts' );
     5745    wp_cache_set( $cache_key, $foundid, 'post-queries' );
    57465746
    57475747    if ( $foundid ) {
     
    59845984
    59855985    $cache_key = "get_pages:$key:$last_changed";
    5986     $cache     = wp_cache_get( $cache_key, 'posts' );
     5986    $cache     = wp_cache_get( $cache_key, 'post-queries' );
    59875987    if ( false !== $cache ) {
    59885988        _prime_post_caches( $cache, false, false );
     
    61496149
    61506150    if ( empty( $pages ) ) {
    6151         wp_cache_set( $cache_key, array(), 'posts' );
     6151        wp_cache_set( $cache_key, array(), 'post-queries' );
    61526152
    61536153        /** This filter is documented in wp-includes/post.php */
     
    61926192    }
    61936193
    6194     wp_cache_set( $cache_key, $page_structure, 'posts' );
     6194    wp_cache_set( $cache_key, $page_structure, 'post-queries' );
    61956195
    61966196    // Convert to WP_Post instances.
     
    73567356    }
    73577357
    7358     wp_cache_set( 'last_changed', microtime(), 'posts' );
     7358    wp_cache_set_posts_last_changed();
    73597359}
    73607360
Note: See TracChangeset for help on using the changeset viewer.