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

    r55334 r55526  
    848848        $last_changed = wp_cache_get_last_changed( 'terms' );
    849849        $cache_key    = 'get_objects_in_term:' . md5( $sql ) . ":$last_changed";
    850         $cache        = wp_cache_get( $cache_key, 'terms' );
     850        $cache        = wp_cache_get( $cache_key, 'term-queries' );
    851851        if ( false === $cache ) {
    852852                $object_ids = $wpdb->get_col( $sql );
    853                 wp_cache_set( $cache_key, $object_ids, 'terms' );
     853                wp_cache_set( $cache_key, $object_ids, 'term-queries' );
    854854        } else {
    855855                $object_ids = (array) $cache;
     
    28592859
    28602860        wp_cache_delete( $object_id, $taxonomy . '_relationships' );
    2861         wp_cache_delete( 'last_changed', 'terms' );
     2861        wp_cache_set_terms_last_changed();
    28622862
    28632863        /**
     
    29572957
    29582958                wp_cache_delete( $object_id, $taxonomy . '_relationships' );
    2959                 wp_cache_delete( 'last_changed', 'terms' );
     2959                wp_cache_set_terms_last_changed();
    29602960
    29612961                /**
     
    35433543        }
    35443544
    3545         wp_cache_delete( 'last_changed', 'terms' );
     3545        wp_cache_set_terms_last_changed();
    35463546
    35473547        /**
     
    36183618        }
    36193619
    3620         wp_cache_set( 'last_changed', microtime(), 'terms' );
     3620        wp_cache_set_terms_last_changed();
    36213621}
    36223622
     
    36313631        wp_cache_delete( 'all_ids', $taxonomy );
    36323632        wp_cache_delete( 'get', $taxonomy );
    3633         wp_cache_delete( 'last_changed', 'terms' );
     3633        wp_cache_set_terms_last_changed();
    36343634
    36353635        // Regenerate cached hierarchy.
Note: See TracChangeset for help on using the changeset viewer.