Make WordPress Core

Opened 16 years ago

Closed 16 years ago

#9048 closed enhancement (fixed)

Don't cache to options table if object cache installed

Reported by: ryan's profile 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 16 years ago.
Sample implementation of *_transient()
9048.2.diff (5.6 KB) - added by ryan 16 years ago.
Prefix transients with _transient_ when storing in DB

Download all attachments as: .zip

Change History (15)

@ryan
16 years ago

Sample implementation of *_transient()

#1 @ryan
16 years ago

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

#2 @markjaquith
16 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.

#3 @DD32
16 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.

#4 follow-up: @azaozz
16 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.

#5 in reply to: ↑ 4 @ryan
16 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.

#6 @westi
16 years ago

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

#7 @ryan
16 years ago

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

@ryan
16 years ago

Prefix transients with _transient_ when storing in DB

#9 @ryan
16 years ago

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

#10 @ryan
16 years ago

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

#11 @ryan
16 years ago

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

#12 @ryan
16 years ago

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

#13 @ryan
16 years ago

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