[wp-trac] [WordPress Trac] #45277: Garbage collect transients
WordPress Trac
noreply at wordpress.org
Sun Nov 4 10:02:01 UTC 2018
#45277: Garbage collect transients
--------------------------+-----------------------------
Reporter: dartiss | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Database | Version: trunk
Severity: normal | Keywords: needs-patch
Focuses: |
--------------------------+-----------------------------
5 years later, I would like to re-open the discussion about the fact that
transients are not correctly housekept (see #20316).
The issue... expired transients are only housekept if the transient is
read. If it is not read, it remains in the database.
The solution... perform a daily garbage collection on expired transients
This was not implemented 5 years ago because "we don't want a core update
to be blamed for breaking a site that incorrectly assumes transients
aren't transient". I would like this discussion to take place again -
during this time, I have implemented the housekeeping solution with my own
plugin (https://wordpress.org/plugins/artiss-transient-cleaner/), which
has had over 73,000 downloads and not a single person reporting issues (in
fact, it's known to fix some issues for some users). I'd really like to
see this issue resolved and my plugin becoming redundant!
I'd also like to take the conversation further than before, where the
solution was via MySQL. This works where transients are stored on the
database, but isn't the case for object caching. I have an alternative
solution that will work for all storage methods...
* Enhance the `set_transient` function (and `set_site_transient`) so that
all transients with an expiry are also stored inside an array, stored on
the options table. This array will contain the transient name and expiry.
* Introduce a daily garbage collection task, which will look through this
array, looking for expired transients
* For all expired transients, use the existing functions (e.g.
`delete_transient`) to remove the relevant transient.
By using this method, no SQL is required, so object cache will be
correctly housekept too.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/45277>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list