From 56f5c869875ad5a80452037e69317792f2353512 Mon Sep 17 00:00:00 2001 From: cxlblm Date: Thu, 26 Oct 2023 22:06:20 +0800 Subject: [PATCH] Fix the issue of using the now function within the ArrayCache in Lumen. (#48826) --- src/Illuminate/Cache/ArrayStore.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Cache/ArrayStore.php b/src/Illuminate/Cache/ArrayStore.php index bfb8a2ca70dc..4cca8cbf6960 100644 --- a/src/Illuminate/Cache/ArrayStore.php +++ b/src/Illuminate/Cache/ArrayStore.php @@ -3,6 +3,7 @@ namespace Illuminate\Cache; use Illuminate\Contracts\Cache\LockProvider; +use Illuminate\Support\Carbon; use Illuminate\Support\InteractsWithTime; class ArrayStore extends TaggableStore implements LockProvider @@ -57,7 +58,7 @@ public function get($key) $expiresAt = $item['expiresAt'] ?? 0; - if ($expiresAt !== 0 && (now()->getPreciseTimestamp(3) / 1000) >= $expiresAt) { + if ($expiresAt !== 0 && (Carbon::now()->getPreciseTimestamp(3) / 1000) >= $expiresAt) { $this->forget($key); return; @@ -188,7 +189,7 @@ protected function calculateExpiration($seconds) */ protected function toTimestamp($seconds) { - return $seconds > 0 ? (now()->getPreciseTimestamp(3) / 1000) + $seconds : 0; + return $seconds > 0 ? (Carbon::now()->getPreciseTimestamp(3) / 1000) + $seconds : 0; } /**