Make WordPress Core


Ignore:
Timestamp:
02/11/2022 06:50:08 PM (3 years ago)
Author:
spacedmonkey
Message:

Cache: Use wp_cache_*_multiple() in core functions.

Implement the wp_cache_add_multiplewp_cache_set_multiple and wp_cache_delete_multiple in a number of core functions after they were introduced in [52700]

Props: spacedmonkey, adamsilverstein, flixos90, mitogh.
Fixes: #55029.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-site.php

    r52205 r52707  
    372372        return;
    373373    }
    374     $site_ids = array();
     374    $site_ids          = array();
     375    $site_data         = array();
     376    $blog_details_data = array();
    375377    foreach ( $sites as $site ) {
    376         $site_ids[] = $site->blog_id;
    377         wp_cache_add( $site->blog_id, $site, 'sites' );
    378         wp_cache_add( $site->blog_id . 'short', $site, 'blog-details' );
    379     }
     378        $site_ids[]                                    = $site->blog_id;
     379        $site_data[ $site->blog_id ]                   = $site;
     380        $blog_details_data[ $site->blog_id . 'short' ] = $site;
     381
     382    }
     383    wp_cache_add_multiple( $site_data, 'sites' );
     384    wp_cache_add_multiple( $blog_details_data, 'blog-details' );
    380385
    381386    if ( $update_meta_cache ) {
Note: See TracChangeset for help on using the changeset viewer.