-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tom Havlik
authored and
Tom Havlik
committed
May 9, 2020
1 parent
9c0a711
commit 4f0afa4
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
local resource = KEYS[1] | ||
local claim = ARGV[1] | ||
local current = redis.call('GET', resource) | ||
if not current then | ||
-- Freshly reserved | ||
redis.call('SET', resource, claim) | ||
return 1 | ||
elseif current == claim then | ||
-- Already reserved | ||
return 0 | ||
end | ||
return {err='BadClaim'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters