feat: fix idempotency cache
This commit is contained in:
parent
42433a8cbf
commit
8684a6e19b
@ -24,6 +24,12 @@ class IdempotencyMiddleware
|
|||||||
$cacheKey = $this->cacheKey($request, $idempotencyKey);
|
$cacheKey = $this->cacheKey($request, $idempotencyKey);
|
||||||
$lockKey = $this->lockKey($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'));
|
$lock = Cache::lock($lockKey, config('slots.idempotency_lock_seconds'));
|
||||||
if (! $lock->get()) {
|
if (! $lock->get()) {
|
||||||
return $this->waitForCachedResponse($cacheKey) ?? $this->inProgressResponse();
|
return $this->waitForCachedResponse($cacheKey) ?? $this->inProgressResponse();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user