[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
Thu Aug 25 07:02:39 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: 4.6
Severity: normal | Resolution:
Keywords: has-patch needs-testing | Focuses: performance
-------------------------------------+------------------------------
Changes (by danieliser):
* keywords: => has-patch needs-testing
Comment:
Patch added. Tested and this allows the reduction of unnecessary queries
like so.
This is how it can be used.
{{{#!php
<?php
if ( ! valid_transient( 'testing' ) ) {
$value = 'value';
set_transient( 'testing', $value, 60 );
} else {
$value = get_transient( 'testing' );
}
}}}
This becomes more useful when useful when using transients for timers &
such.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37040#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list