[wp-trac] [WordPress Trac] #37040: Enhancement: new function to validate a transient exists, and isn't expired without extra query
WordPress Trac
noreply at wordpress.org
Mon Jun 6 23:34:53 UTC 2016
#37040: Enhancement: new function to validate a transient exists, and isn't expired
without extra query
--------------------------------+-----------------------------
Reporter: danieliser | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Options, Meta APIs | Version: trunk
Severity: normal | Keywords:
Focuses: performance |
--------------------------------+-----------------------------
Currently calling get_transient makes 2 queries, the first to validate if
the transient exists & is not expired, the second to get the transient
value.
I propose creating a new function that does the job of the first query
only. It should validate that the transient exists and hasn't expired
returning a boolean.
The get_transient should then be modified to call that function rather
than get_option.
The purpose here is to allow plugin / theme developers to minimize queries
even further.
Example: If all I need to do is check for a valid transient that only
requires 1 query, I don't always need the value, just need to know whether
it should be refreshed.
In that case I could call valid_transient( 'transient' ).
Since that value can be cached if I later need the full value then only
one additional query would be needed.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37040>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list