Skip to content

Commit 25daba4

Browse files
authored
Merge pull request #9 from laravel-enso/fixes/usesCacheLifeTime
uses cacheLifeTime
2 parents 51ac226 + 03d5ff6 commit 25daba4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Traits/Rememberable.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace LaravelEnso\Rememberable\Traits;
44

5+
use Carbon\Carbon;
56
use Illuminate\Support\Facades\Cache;
67
use Illuminate\Support\Facades\Config;
78

@@ -37,7 +38,12 @@ public static function cacheGet($id)
3738

3839
public function cachePut()
3940
{
40-
Cache::put($this->getCacheKey(), $this);
41+
$limit = $this->getCacheLifetime();
42+
$key = $this->getCacheKey();
43+
44+
return $limit === 'forever'
45+
? Cache::forever($key, $this)
46+
: Cache::put($key, $this, Carbon::now()->addMinutes($limit));
4147
}
4248

4349
public function getCacheKey()

0 commit comments

Comments
 (0)