Prime blogs of user cache from old cache to avoid mass DB requests on upgrade. see #14379

git-svn-id: http://svn.automattic.com/wordpress/trunk@16225 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-11-06 18:45:20 +00:00
parent 39e775daeb
commit 59bffc3071
1 changed files with 12 additions and 0 deletions

View File

@ -616,6 +616,18 @@ function get_blogs_of_user( $id, $all = false ) {
}
$blogs = wp_cache_get( 'blogs_of_user-' . $id, 'users' );
// Try priming the new cache from the old cache
if ( false === $blogs ) {
$cache_suffix = $all ? '_all' : '_short';
$blogs = wp_cache_get( 'blogs_of_user_' . $id . $cache_suffix, 'users' );
if ( is_array( $blogs ) ) {
$blogs = array_keys( $blogs );
if ( $all )
wp_cache_set( 'blogs_of_user-' . $id, $blogs, 'users' );
}
}
if ( false === $blogs ) {
$user = get_userdata( (int) $id );
if ( !$user )