From 8684a6e19b6da3009595d7301c0a5fe8efa16208 Mon Sep 17 00:00:00 2001 From: rinsvent Date: Mon, 18 May 2026 08:50:13 +0700 Subject: [PATCH] feat: fix idempotency cache --- app/Http/Middleware/IdempotencyMiddleware.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Http/Middleware/IdempotencyMiddleware.php b/app/Http/Middleware/IdempotencyMiddleware.php index 45bbeee..c94e5a9 100644 --- a/app/Http/Middleware/IdempotencyMiddleware.php +++ b/app/Http/Middleware/IdempotencyMiddleware.php @@ -24,6 +24,12 @@ class IdempotencyMiddleware $cacheKey = $this->cacheKey($request, $idempotencyKey); $lockKey = $this->lockKey($request, $idempotencyKey); + // Проверяем чтобы не выполнять код + $cached = Cache::get($cacheKey); + if (is_array($cached)) { + return $this->replayResponse($cached); + } + $lock = Cache::lock($lockKey, config('slots.idempotency_lock_seconds')); if (! $lock->get()) { return $this->waitForCachedResponse($cacheKey) ?? $this->inProgressResponse();