Make WordPress Core

Opened 9 years ago

Last modified 3 years ago

#10274 closed defect (bug)

Simplify options caching — at Version 2

Reported by: ryan Owned by: ryan
Milestone: Priority: low
Severity: minor Version:
Component: Cache API Keywords:
Focuses: Cc:

Description (last modified by ryan)

Instead of caching all options and their values to a big array, let's cache only the option names to an array and cache the values individually. The option name cache will be passed to wp_cache_get_multi() (which needs to be added) at startup to prime the option cache. Here's the flow.

(List of option names cached to all_options)

First page load:

  • wp_cache_get all_options
  • Nothing is cached to all_options, so query db for all option names and values
  • Loop over DB results, wp_cache_add each option and construct all_options list.
  • wp_cache_set all_options with the options list * Cache for each option is now primed via the wp_cache_adds.

Next page load:

  • wp_get_get all_options
  • all_options has cached list of option names, pass those names to wp_cache_get_multi
  • get_multi does one memcached request for all options
  • cache is now primed for all options, each option in its own bucket, no need to query DB

Change History (3)

9 years ago

Untested and incomplete and possibly crackheaded

#1 @ryan
9 years ago

The notoptions cache is not really dealt with yet. On wp.com and some other WPMU setups, all options are autoloaded so you can assume that if an option isn't present after all options are loaded it does not exist. There's no need for a separate notoptions cache. We can't do that on WP. The query in that patch makes the assumption that all options are autoloaded, so that will have to change. The patch and this ticket are simply meant to get discussion flowing.

#2 @ryan
9 years ago

  • Description modified (diff)
Note: See TracTickets for help on using tickets.