Make WordPress Core


Ignore:
Timestamp:
08/02/2012 06:31:14 PM (13 years ago)
Author:
ryan
Message:

Introduce wp_cache_switch_to_blog() and WP_Object_Cache::switch_to_blog() as a lighter/faster way to switch the cache to a new blog id.

Add the blog id to the cache keys for multisite installs.

Use wp_cache_switch_to_blog() instead of wp_cache_init() in switch_to_blog().

Use wp_cache_switch_to_blog() instead of wp_cache_reset() in wp_start_object_cache().

Deprecate wp_cache_reset().

This avoids the many queries needed to re-prime the cache after switch_to_blog() on multisite installs using the default cache backend.

fixes #21434

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/load.php

    r21363 r21403  
    382382 */
    383383function wp_start_object_cache() {
    384     global $_wp_using_ext_object_cache;
     384    global $_wp_using_ext_object_cache, $blog_id;
    385385
    386386    $first_init = false;
     
    404404    // Reset signals to the cache that global IDs have changed and it may need to update keys
    405405    // and cleanup caches.
    406     if ( !$first_init && function_exists('wp_cache_reset') )
    407         wp_cache_reset();
     406    if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) )
     407        wp_cache_switch_to_blog( $blog_id );
    408408    else
    409409        wp_cache_init();
Note: See TracChangeset for help on using the changeset viewer.