WordPress.org

Make WordPress Core

Changeset 4798


Ignore:
Timestamp:
01/25/2007 12:12:08 AM (14 years ago)
Author:
markjaquith
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.