License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html
Housekeep expired transients from your options table
"Transients are a simple and standardized way of storing cached data in the WordPress database temporarily by giving it a custom name and a timeframe after which it will expire and be deleted."
Unfortunately, expired entries will only be deleted if you attempt to access the transient again. If you don't access the transient then, even though it's expired, WordPress will not remove it. This is a known "issue" and is due to be corrected at some point in the WordPress core code.
Why is this a problem? Transients are often used by plugins to "cache" data (my own plugins included). Because of the housekeeping problems this means that expired data can be left and build up, resulting in a bloated database table.
Meantime, this plugin is the solution, using the same proposed method as the WordPress core change will use. Simply activate the plugin, sit back and enjoy a much cleaner, smaller options table. It also adds the additional recommendation that after a database upgrade all transients will be cleared down.
Transients an options screen exists allowing you to tweak which of the various housekeeping you'd like to happen, including the ability to perform an ad-hoc run. You can also request an optimization of the options table to give your system a real "pep"!
This plugin, and all support, is supplied for free, but donations are always welcome.
I'd like to thank WordPress Developer Andrew Nacin for discussing this issue with and providing me with the Trac details. Also, I'd like to acknowledge the useful article at Everybody Staze for ensuring my proposed solution wasn't totally mad, and W-Shadow.com for the cleaning code.
- Upload the entire
artiss-transient-cleanerfolder to your wp-content/plugins/ directory and activate the plugin through the 'Plugins' menu in WordPress.
- Alternatively, use the Add Plugins option within WordPress to search for and install the plugin.
- That's it - you're done. Options can be changed in Administration via the Tools->Transients screen.
Frequently Asked Questions
How often will expired transients be cleared down?
It runs alongside the existing trash deletion, which is timed to run once a day. However, it will also run whenever you activate the plugin, ensuring that you can immediately test the results.
Even after performing the scheduled housekeeping there are still expired transients left
This can happen when transients become "orphaned". Each transient consists of 2 record - one holds the expiry time and the other the actual data. If one is removed without the other then this will then cause problems for the scheduled housekeeping.
In this situation the Database Upgrade run, which removes all transients even if they're orphaned, will be the solution.
Administration screen showing contextual help screen
- Maintenance: Split files because of additional code size
- Maintenance: Removed run upon activation
- Enhancement: Improved transient cleaning code efficiency (including housekeeping MU wide transients)
- Enhancement: Added administration screen (Tools->Transients) to allow ad-hoc runs and specify run options
- Enhancement: Show within new admin screen whether orphaned transients have been found (in this case full clear of the option table is recommended)
- Enhancement: Added internationalisation
- Enhancement: If external memory cache is in use display an admin box to indicate this plugin is not required
- Enhancement: Transients will be initially housekept when the plugin is activated
- Initial release