Skip to content

Commit

Permalink
expiration can be specified as string
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 5, 2014
1 parent 802bf2d commit c04c331
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/twitter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Twitter
/**#@-*/

/** @var int */
public static $cacheExpire = 1800; // 30 min
public static $cacheExpire = '30 minutes';

/** @var string */
public static $cacheDir;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit c04c331

Please sign in to comment.