Index: wp-includes/cache.php
===================================================================
--- wp-includes/cache.php	(revision 23584)
+++ wp-includes/cache.php	(working copy)
@@ -608,6 +608,22 @@
 	}
 
 	/**
+	 * Retrieve array of non-persistent cache groups
+	 *
+	 * @since 3.6.0
+	 *
+	 * @return array
+	 */
+	function get_non_persistent_groups() {
+		$all_groups = array_keys( $this->cache );
+		$all_groups = array_fill_keys( $all_groups, true );
+
+		$non_persistent_groups = array_diff_key( $all_groups, $this->global_groups );
+
+		return $non_persistent_groups;
+	}
+
+	/**
 	 * Utility function to determine whether a key exists in the cache.
 	 *
 	 * @since 3.4.0
Index: wp-includes/ms-blogs.php
===================================================================
--- wp-includes/ms-blogs.php	(revision 23584)
+++ wp-includes/ms-blogs.php	(working copy)
@@ -518,27 +518,11 @@
 	$prev_blog_id = $GLOBALS['blog_id'];
 	$GLOBALS['blog_id'] = $new_blog;
 
-	if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
+	if ( function_exists( 'wp_cache_switch_to_blog' ) )
 		wp_cache_switch_to_blog( $new_blog );
-	} else {
-		global $wp_object_cache;
+	else
+		_ms_cache_switch_fallback();
 
-		if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
-			$global_groups = $wp_object_cache->global_groups;
-		else
-			$global_groups = false;
-
-		wp_cache_init();
-
-		if ( function_exists( 'wp_cache_add_global_groups' ) ) {
-			if ( is_array( $global_groups ) )
-				wp_cache_add_global_groups( $global_groups );
-			else
-				wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', ' blog-id-cache' ) );
-			wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
-		}
-	}
-
 	if ( did_action( 'init' ) ) {
 		$wp_roles->reinit();
 		$current_user = wp_get_current_user();
@@ -579,27 +563,11 @@
 	$GLOBALS['blog_id'] = $blog;
 	$GLOBALS['table_prefix'] = $wpdb->prefix;
 
-	if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
+	if ( function_exists( 'wp_cache_switch_to_blog' ) )
 		wp_cache_switch_to_blog( $blog );
-	} else {
-		global $wp_object_cache;
+	else
+		_ms_cache_switch_fallback();
 
-		if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
-			$global_groups = $wp_object_cache->global_groups;
-		else
-			$global_groups = false;
-
-		wp_cache_init();
-
-		if ( function_exists( 'wp_cache_add_global_groups' ) ) {
-			if ( is_array( $global_groups ) )
-				wp_cache_add_global_groups( $global_groups );
-			else
-				wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', ' blog-id-cache' ) );
-			wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
-		}
-	}
-
 	if ( did_action( 'init' ) ) {
 		$wp_roles->reinit();
 		$current_user = wp_get_current_user();
@@ -626,6 +594,50 @@
 }
 
 /**
+ * Cache reset process used when switch_to_blog() and restore_current_blog() are called.
+ * Necessary only when persistent object cache doesn't have a wp_cache_switch_to_blog() function.
+ *
+ * @since 3.6.0
+ *
+ * @global $wp_object_cache
+ *
+ * @uses _wp_cache_get_all_nonpersistent_groups
+ * @uses wp_cache_init
+ * @uses wp_cache_add_global_groups
+ * @uses wp_cache_add_nonpersistent_groups
+ * @return null
+ */
+function _ms_cache_switch_fallback() {
+	global $wp_object_cache;
+
+	if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
+		$global_groups = $wp_object_cache->global_groups;
+	else
+		$global_groups = false;
+
+	if ( is_object( $wp_object_cache ) && method_exists( $wp_object_cache, 'get_non_persistent_groups' ) )
+		$non_persistent_groups = $wp_object_cache->get_non_persistent_groups();
+	else
+		$non_persistent_groups = false;
+
+	wp_cache_init();
+
+	if ( function_exists( 'wp_cache_add_global_groups' ) ) {
+		if ( is_array( $global_groups ) )
+			wp_cache_add_global_groups( $global_groups );
+		else
+			wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'user_meta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'global-posts', ' blog-id-cache' ) );
+	}
+
+	if ( function_exists( 'wp_cache_add_non_persistent_groups' ) ) {
+		if ( is_array( $non_persistent_groups ) )
+			wp_cache_add_non_persistent_groups( $non_persistent_groups );
+		else
+			wp_cache_add_non_persistent_groups( array( 'comment', 'counts', 'plugins' ) );
+	}
+}
+
+/**
  * Check if a particular blog is archived.
  *
  * @since MU
