Skip to content

Commit 6a47c9d

Browse files
committed
Allow infinite cache
1 parent eb47199 commit 6a47c9d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

config/torchlight.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// leave this blank your default app cache will be used.
77
'cache' => env('TORCHLIGHT_CACHE_DRIVER'),
88

9-
// Cache blocks for 30 days.
9+
// Cache blocks for 30 days. Set null to store permanently
1010
'cache_seconds' => env('TORCHLIGHT_CACHE_TTL', 60 * 60 * 24 * 30),
1111

1212
// Which theme you want to use. You can find all of the themes at

src/Client.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,13 @@ protected function setCacheFromBlocks(Collection $blocks, Collection $ids)
172172
}
173173

174174
if (count($value)) {
175-
$seconds = (int)Torchlight::config('cache_seconds', 7 * 24 * 60 * 60);
176-
Torchlight::cache()->put($this->cacheKey($block), $value, $seconds);
175+
$seconds = Torchlight::config('cache_seconds', 7 * 24 * 60 * 60);
176+
177+
if (is_null($seconds)) {
178+
Torchlight::cache()->forever($this->cacheKey($block), $value);
179+
} else {
180+
Torchlight::cache()->put($this->cacheKey($block), $value, (int)$seconds);
181+
}
177182
}
178183
});
179184
}

0 commit comments

Comments
 (0)