WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/12/2010 05:06:43 PM (12 years ago)
Author:
ryan
Message:

Preload commonly loaded site options when running multisite without a persistent cache. Introduce wp_cache_reset() and call it instead of wp_cache_init() when re-initing after the blog ID chanages to avoid throwing out the entire cache. Pass cached site options through the site option filter when fetching.

File:
1 edited

Legend:

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

    r13064 r13066  
    319319 */
    320320function wp_start_object_cache() {
    321     if ( ! function_exists( 'wp_cache_init' ) ) {
     321    $first_init = false;
     322    if ( ! function_exists( 'wp_cache_init' ) ) {
    322323        global $_wp_using_ext_object_cache;
    323324        if ( file_exists( WP_CONTENT_DIR . '/object-cache.php' ) ) {
     
    328329            $_wp_using_ext_object_cache = false;
    329330        }
    330     }
    331 
    332     wp_cache_init();
     331        $first_init = true;
     332    }
     333
     334    // If cache supports reset, reset instead of init if already initialized.
     335    // Reset signals to the cache that global IDs have changed and it may need to update keys
     336    // and cleanup caches.
     337    if ( !$first_init && function_exists('wp_cache_reset') )
     338        wp_cache_reset();
     339    else
     340        wp_cache_init();
     341
    333342    if ( function_exists( 'wp_cache_add_global_groups' ) ) {
    334343        wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'site-transient', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss' ) );
Note: See TracChangeset for help on using the changeset viewer.