-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #116 issue about Laravel cache duration in minutes or seconds
- Loading branch information
Showing
1 changed file
with
12 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,8 +43,7 @@ public function fetch($key) | |
public function save($key, CacheEntry $data) | ||
{ | ||
try { | ||
// getTTL returns seconds, Laravel needs minutes | ||
$lifeTime = $data->getTTL() / 60; | ||
$lifeTime = $this->getLifeTime($data); | ||
if ($lifeTime === 0) { | ||
return $this->cache->forever( | ||
$key, | ||
|
@@ -71,4 +70,15 @@ public function delete($key) | |
{ | ||
return $this->cache->forget($key); | ||
} | ||
|
||
protected function getLifeTime(CacheEntry $data) | ||
{ | ||
$version = app()->version(); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
GrahamCampbell
|
||
if (preg_match('/^\d+(\.\d+)?(\.\d+)?/', $version) && version_compare($version, '5.8.0') < 0) { | ||
// getTTL returns seconds, Laravel needs minutes before v5.8 | ||
return $data->getTTL() / 60; | ||
} | ||
|
||
return $data->getTTL(); | ||
} | ||
} |
The
app
function only exists if you install the entire laravel framework.