Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoload should be 'no' #10

Closed
wants to merge 2 commits into from

Conversation

markjaquith
Copy link
Owner

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
Copy link
Owner

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.

…g it indefinite.

* With the default options-table based transient cache, indefinitely stored transients are autoloaded.
* By setting an expiration date in the far-future, it is *effectively* indefinite, but we get the benefit of no autoloading of what might be a very large options row.

props to @YousefED for bringing the issue to my attention. fixes #10
@markjaquith
Copy link
Owner

How does f388488 look?

@YousefED
Copy link
Contributor Author

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants