[wp-trac] Re: [WordPress Trac] #2268: get_option() on non-existent option always invokes new query

WordPress Trac wp-trac at lists.automattic.com
Thu Feb 1 10:02:29 GMT 2007


#2268: get_option() on non-existent option always invokes new query
-------------------------------------+--------------------------------------
 Reporter:  markjaquith              |        Owner:  markjaquith
     Type:  defect                   |       Status:  closed     
 Priority:  high                     |    Milestone:  2.2        
Component:  Optimization             |      Version:  2.1        
 Severity:  normal                   |   Resolution:  fixed      
 Keywords:  has-patch needs-testing  |  
-------------------------------------+--------------------------------------
Comment (by markjaquith):

 To explain this a bit:

  * Two pseudo-options are stored in the object cache (just there, not in
 the DB)
  * 'notoptions' stores all attempted non-options so that the DB isn't
 accessed more than once trying to load these options that don't exist
  * 'alloptions' stores all autoloaded options. The first time any option
 is queried, 'alloptions' will be populated (either from the DB, or from a
 persistent object cache). If the option is in there (likely, most options
 are autoloaded), it'll be read from there. So you just have one cache read
 for all your autoloaded options.
  * Non-autoloaded options revert to the options cache as before (one item
 per cache entry).
  * Since the loading of the autoloaded options is used by get_option(),
 people using alternative object caches will no longer see individual
 queries for each option on the first load (i.e. with an empty object
 cache)

 All of this should be transparent. As long as you use get_option(),
 add_option(), update_option(), and delete_option(), it should be like
 nothing ever happened.

 This should reduce cache misses to zero (or close to it), and it should
 reduce redundant queries.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/2268#comment:15>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list