WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#9048 closed enhancement (fixed)

Don't cache to options table if object cache installed

Reported by: ryan Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

RSS feeds, rewrite rules, and other things that should be in a cache are actually stored in the options table since the default cache does not persist data beyond the current page load. For blogs where an object cache backend that persists across page loads is installed, we should move these "options" out of the options table and into the cache.

My suggestion is to add a set of *_transient() functions that are used instead of *_option() for transient data that really belongs in the cache. An alternative is to have the *_option() functions check a list of options that should be transient and send transients to the cache instead of the options table. Plugins could add to the list.

Attachments (2)

9048.diff (5.5 KB) - added by ryan 5 years ago.
Sample implementation of *_transient()
9048.2.diff (5.6 KB) - added by ryan 5 years ago.
Prefix transients with _transient_ when storing in DB

Download all attachments as: .zip

Change History (15)

ryan5 years ago

Sample implementation of *_transient()

comment:1 ryan5 years ago

Patch implements *_transient() API and switches rewrite_rules and the RSS cache to it.

comment:2 markjaquith5 years ago

An alternative is to have the *_option() functions check a list of options that should be transient and send transients to the cache instead of the options table.

Is there any chance that plugins will be calling the *_option() functions on these transient "options?" If so, they'll get a different result than *_transient() would. Then again, we might not care. The data is transient, after all.

comment:3 DD325 years ago

Then again, we might not care. The data is transient, after all.

If theres any plugins using it (ie. a Feed replacement plugin) thenit'd be best to encourage them to use it too i would think..

Theres very few cases where a plugin would need direct access to most of the mentioned items.

comment:4 follow-up: azaozz5 years ago

Perhaps we could have autoload = yes|no|transient, so things like _transient_flush() (delete all transient items) would work. Or maybe add another column to the options table to mark entries as transient.

comment:5 in reply to: ↑ 4 ryan5 years ago

The RSS stuff is buried in the Magpie class and rewrite_rules should be accessed through WP_Rewrite::wp_rewrite_rules(), so I don't think plugins should be doing get_option() on them.

comment:6 westi5 years ago

Maybe we should/could rename the things we are marking as transient to ensure there is no issue.

comment:7 ryan5 years ago

Rename them to start or end with "cache", perhaps.

ryan5 years ago

Prefix transients with _transient_ when storing in DB

comment:9 ryan5 years ago

(In [10513]) Flag if using external object cache. see #9048

comment:10 ryan5 years ago

(In [10515]) Use transient for update_core, update_plugins, update_themes. see #9048

comment:11 ryan5 years ago

(In [10519]) Use transient for doing_cron. see #9048

comment:12 ryan5 years ago

(In [10533]) Add transient_* filter. see #9048

comment:13 ryan5 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.