mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-02 11:44:33 +00:00
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 git-svn-id: https://develop.svn.wordpress.org/trunk@21403 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -381,7 +381,7 @@ function wp_set_wpdb_vars() {
|
||||
* @since 3.0.0
|
||||
*/
|
||||
function wp_start_object_cache() {
|
||||
global $_wp_using_ext_object_cache;
|
||||
global $_wp_using_ext_object_cache, $blog_id;
|
||||
|
||||
$first_init = false;
|
||||
if ( ! function_exists( 'wp_cache_init' ) ) {
|
||||
@@ -403,8 +403,8 @@ function wp_start_object_cache() {
|
||||
// If cache supports reset, reset instead of init if already initialized.
|
||||
// Reset signals to the cache that global IDs have changed and it may need to update keys
|
||||
// and cleanup caches.
|
||||
if ( !$first_init && function_exists('wp_cache_reset') )
|
||||
wp_cache_reset();
|
||||
if ( ! $first_init && function_exists( 'wp_cache_switch_to_blog' ) )
|
||||
wp_cache_switch_to_blog( $blog_id );
|
||||
else
|
||||
wp_cache_init();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user