markjaquith / WP-TLC-Transients

GNU General Public License v2.0
341 stars 37 forks source link

autoload should be 'no' #10

Closed YousefED closed 11 years ago

YousefED commented 11 years ago

The transients are stored in wp_options with autoload='yes'. This means if you're storing a lot of different TLC transients with a lot of data (e.g. fetching and caching many URLs), Wordpress will take long to load all the options with autoload='yes' (including the transients), which can cause performance issues.

I think it would be better to store the transients with autoload='no'. Unfortunately, I didn't see a quick fix, because the WordPress transients API only sets autoload when an explicit expiration is set.

markjaquith commented 11 years ago

Right, so WordPress only sets autoload to no when an explicit expiration is set. I've not set an expiration, since TLC transients does its own expiration. But what I could do is just set a transient expiration that's really far in the future. That way, it would effectively be stored, and the option wouldn't be autoloaded.

markjaquith commented 11 years ago

How does f3884889fb6940784582bb4aa957a504894c370d look?

YousefED commented 11 years ago

Thanks for the quick fix, I'll test it on one of our websites. Just to be sure I think it would be smart to throw an error when the expiration is meant to be after a year, or set the WP expiration to $expiration+$oneyear to be safe.

markjaquith commented 11 years ago

I like the idea of $expiration plus one year: that's a safer way of doing what I was intending.