From a9cc55f19006f3d240465c868cfd7dfc60d28bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Nagy?= Date: Mon, 4 Dec 2023 14:47:27 +0100 Subject: [PATCH 1/2] Fixed the CacheCheck causing race conditions in some cases --- src/Checks/Checks/CacheCheck.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Checks/Checks/CacheCheck.php b/src/Checks/Checks/CacheCheck.php index d60ed2eb..9ab5b76b 100644 --- a/src/Checks/Checks/CacheCheck.php +++ b/src/Checks/Checks/CacheCheck.php @@ -45,9 +45,13 @@ protected function canWriteValuesToCache(?string $driver): bool { $expectedValue = Str::random(5); - Cache::driver($driver)->put('laravel-health:check', $expectedValue, 10); + $cacheName = "health:check-{$expectedValue}"; - $actualValue = Cache::driver($driver)->get('laravel-health:check'); + Cache::driver($driver)->put($cacheName, $expectedValue, 10); + + $actualValue = Cache::driver($driver)->get($cacheName); + + Cache::driver($driver)->forget($cacheName); return $actualValue === $expectedValue; } From 48ffec9ad2f663cd006faa99a2764440cd461a29 Mon Sep 17 00:00:00 2001 From: jonnyka Date: Mon, 4 Dec 2023 14:53:12 +0100 Subject: [PATCH 2/2] Update CacheCheck.php --- src/Checks/Checks/CacheCheck.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Checks/Checks/CacheCheck.php b/src/Checks/Checks/CacheCheck.php index 9ab5b76b..b051b5bc 100644 --- a/src/Checks/Checks/CacheCheck.php +++ b/src/Checks/Checks/CacheCheck.php @@ -45,7 +45,7 @@ protected function canWriteValuesToCache(?string $driver): bool { $expectedValue = Str::random(5); - $cacheName = "health:check-{$expectedValue}"; + $cacheName = "laravel-health:check-{$expectedValue}"; Cache::driver($driver)->put($cacheName, $expectedValue, 10);