Changeset 4798

Show
Ignore:
Timestamp:
01/25/07 00:12:08 (2 years ago)
Author:
markjaquith
Message:

Cache the non-existence of options to prevent redundant queries. props davidhouse. fixes #2268

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/functions.php

    r4752 r4798  
    204204    global $wpdb; 
    205205 
     206    // prevent non-existent options from triggering multiple queries 
     207    if ( true === wp_cache_get($setting, 'notoptions') ) 
     208        return false; 
     209 
    206210    $value = wp_cache_get($setting, 'options'); 
    207211 
     
    216220            $value = $row->option_value; 
    217221            wp_cache_set($setting, $value, 'options'); 
    218         } else { 
     222        } else { // option does not exist, so we must cache its non-existence 
     223            wp_cache_set($setting, true, 'notoptions'); 
    219224            return false; 
    220225        } 
     
    274279        return true; 
    275280    } 
     281 
     282    if ( true === wp_cache_get($option_name, 'notoptions') ) 
     283        wp_cache_delete($option_name, 'notoptions'); 
    276284 
    277285    $_newvalue = $newvalue;