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.
Built from https://develop.svn.wordpress.org/trunk@55526


git-svn-id: http://core.svn.wordpress.org/trunk@55048 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
spacedmonkey
2023-03-10 16:30:03 +00:00
parent df7b417d64
commit 1bf93a87a4
14 changed files with 53 additions and 53 deletions

View File

@@ -1154,12 +1154,12 @@ function _find_post_by_old_slug( $post_type ) {
$key = md5( $query );
$last_changed = wp_cache_get_last_changed( 'posts' );
$cache_key = "find_post_by_old_slug:$key:$last_changed";
$cache = wp_cache_get( $cache_key, 'posts' );
$cache = wp_cache_get( $cache_key, 'post-queries' );
if ( false !== $cache ) {
$id = $cache;
} else {
$id = (int) $wpdb->get_var( $query );
wp_cache_set( $cache_key, $id, 'posts' );
wp_cache_set( $cache_key, $id, 'post-queries' );
}
return $id;
@@ -1197,7 +1197,7 @@ function _find_post_by_old_date( $post_type ) {
$key = md5( $query );
$last_changed = wp_cache_get_last_changed( 'posts' );
$cache_key = "find_post_by_old_date:$key:$last_changed";
$cache = wp_cache_get( $cache_key, 'posts' );
$cache = wp_cache_get( $cache_key, 'post-queries' );
if ( false !== $cache ) {
$id = $cache;
} else {
@@ -1206,7 +1206,7 @@ function _find_post_by_old_date( $post_type ) {
// Check to see if an old slug matches the old date.
$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' ) ) );
}
wp_cache_set( $cache_key, $id, 'posts' );
wp_cache_set( $cache_key, $id, 'post-queries' );
}
}