#
zhou zhou
18 小时以前 c1c045cad0f39a38409de117e9ddf470804b0d81
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
local mode = ARGV[1]
local occupyValue = ARGV[2]
local taskValue = ARGV[3]
local ttl = tonumber(ARGV[4])
 
if mode == 'PUTAWAY' then
  if redis.call('exists', KEYS[1]) == 1 or redis.call('exists', KEYS[2]) == 1 then
    return 0
  end
  redis.call('psetex', KEYS[1], ttl, occupyValue)
  redis.call('psetex', KEYS[2], ttl, taskValue)
  return 1
end
 
if redis.call('exists', KEYS[2]) == 1 then
  return 0
end
redis.call('psetex', KEYS[2], ttl, taskValue)
return 1