mirror of
https://github.com/nodemailer/wildduck.git
synced 2024-11-10 17:47:07 +08:00
24 lines
No EOL
480 B
Lua
24 lines
No EOL
480 B
Lua
local key = KEYS[1];
|
|
|
|
local identifier = ARGV[1];
|
|
local ttl = tonumber(ARGV[2]) or 0;
|
|
|
|
if redis.call("EXISTS", key) == 1 then
|
|
|
|
local existing = redis.call("GET", key);
|
|
if existing == identifier then
|
|
redis.call("EXPIRE", key, ttl);
|
|
return 1;
|
|
else
|
|
return nil;
|
|
end
|
|
|
|
else
|
|
local result = redis.call("SET", key, identifier);
|
|
if result then
|
|
redis.call("EXPIRE", key, ttl);
|
|
return 2;
|
|
else
|
|
return nil;
|
|
end
|
|
end |