From c04c331c8c52a6b162791e3a5f541c6cf466019e Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 5 Nov 2014 01:15:13 +0100 Subject: [PATCH] expiration can be specified as string --- src/twitter.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/twitter.class.php b/src/twitter.class.php index fbdb7f7..a23f2cf 100644 --- a/src/twitter.class.php +++ b/src/twitter.class.php @@ -25,7 +25,7 @@ class Twitter /**#@-*/ /** @var int */ - public static $cacheExpire = 1800; // 30 min + public static $cacheExpire = '30 minutes'; /** @var string */ public static $cacheDir; @@ -304,7 +304,8 @@ public function cachedRequest($resource, array $data = NULL, $cacheExpire = NULL . '.json'; $cache = @json_decode(@file_get_contents($cacheFile)); // intentionally @ - if ($cache && @filemtime($cacheFile) + $cacheExpire > time()) { // intentionally @ + $expiration = is_string($cacheExpire) ? strtotime($cacheExpire) - time() : $cacheExpire; + if ($cache && @filemtime($cacheFile) + $expiration > time()) { // intentionally @ return $cache; }