From f3884889fb6940784582bb4aa957a504894c370d Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Wed, 19 Dec 2012 20:57:37 -0500 Subject: [PATCH] Set a WP transient expiration one year in the future instead of making it indefinite. * With the default options-table based transient cache, indefinitely stored transients are autoloaded. * By setting an expiration date in the far-future, it is *effectively* indefinite, but we get the benefit of no autoloading of what might be a very large options row. props to @YousefED for bringing the issue to my attention. fixes #10 --- tlc-transients.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tlc-transients.php b/tlc-transients.php index d411098..462f9e7 100644 --- a/tlc-transients.php +++ b/tlc-transients.php @@ -94,9 +94,9 @@ public function fetch_and_cache() { public function set( $data ) { // We set the timeout as part of the transient data. - // The actual transient has no TTL. This allows for soft expiration. + // The actual transient has a far-future TTL. This allows for soft expiration. $expiration = ( $this->expiration > 0 ) ? time() + $this->expiration : 0; - set_transient( 'tlc__' . $this->key, array( $expiration, $data ) ); + set_transient( 'tlc__' . $this->key, array( $expiration, $data ), 31536000 ); // 60*60*24*365 ~= one year return $this; }