[wp-hackers] Transients that are not re-used after their expiry are never garbage-collected
David Anderson
david at wordshell.net
Fri May 3 21:53:56 UTC 2013
> Why would you have a transient with a unique key? Or a key that
> changes? This sort of defeats the point of using a transient in the
> first place.
>
> Sounds to me like you should fix the code that is using transients incorrectly.
Two examples of where I've used transients that are liable to not get
garbage collected are:
1) URLs that are only intended to be available for a limited time
period, and then to expire. A user is invited to visit the URL (e.g. to
change their credentials, or take a quiz). The transient stores
information about the invitation. When the invitation expires (via the
transient expiring), that information perishes with it. But, if the user
never actually visits the URL, then WP's lack of garbage collection will
leave this data present forever.
2) Recording whether a particular file (identified via a hash of its
filename) has had a particular operation performed on it (e.g. upload to
backup - this may not complete all in one go, so information about the
upload can be stored for a later attempt via a transient).
The Codex page just describes transients as "a simple and standardized
way of storing cached data in the database temporarily". I don't see any
indication in there that the above two use cases are incorrect, or don't
fit that description somehow.
David
--
WordShell - WordPress fast from the CLI - www.wordshell.net
More information about the wp-hackers
mailing list