diff --git a/app/Support/BatchDispatchLock.php b/app/Support/BatchDispatchLock.php index 14f8c90..e973bd5 100644 --- a/app/Support/BatchDispatchLock.php +++ b/app/Support/BatchDispatchLock.php @@ -22,10 +22,28 @@ class BatchDispatchLock int $ttlSeconds = 60, string $value = '1', ): bool { - $orderIds = array_values(array_map('intval', $orderIds)); - - $lockKey = $namespace . ':' . md5($scope . '|' . $filterSummary . '|' . implode(',', $orderIds) . '|' . $limit); + $lockKey = static::makeKey($namespace, $scope, $filterSummary, $orderIds, $limit); return Cache::add($lockKey, $value, $ttlSeconds); } + + /** + * @param int[] $orderIds + */ + public static function makeKey( + string $namespace, + string $scope, + string $filterSummary, + array $orderIds, + int $limit, + ): string { + $orderIds = array_values(array_map('intval', $orderIds)); + + return $namespace . ':' . md5($scope . '|' . $filterSummary . '|' . implode(',', $orderIds) . '|' . $limit); + } + + public static function getExistingValue(string $lockKey): mixed + { + return Cache::get($lockKey); + } }