WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#19967 closed enhancement (invalid)

Caching get_option(), set_option() and update_option()

Reported by: egorpromo Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.3.1
Component: General Keywords:
Focuses: Cc:

Description

I propose create caching for some wordpress function like get_option(), set_option() and update_option().
May be it's better not to request data from wp_options base of mysql all time. Better way is request all data from wp_options table at once and save it in global variable. So when we use get_option() we don't request data from database but request data from php global variable. And when we save data using set_option() we save data in wp_options table and save it in global variable yet. Later if we will use get_option() in script we will not request to mysql.

Change History (2)

comment:1 ocean902 years ago

Options are already cached (at least with autoload = true) or did I miss something?

comment:2 duck_2 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

The Options API performs caching with the caching API which means that by default it's non-persistent (as you suggest with a global) and can also be persistent when using an external caching solution.

See the wp_cache_get(), wp_cache_set() and wp_load_alloptions() calls in functions.php in 3.3.1:

Note: See TracTickets for help on using tickets.