if redis.call("exist",KEYS[1] == 1)
then
local productNum =tonumber(redis.call("get",KEYS[1]))
local subNum = tonumber(ARGV[1])
if(productNum <= 0)
then
return -4
end
if(subNum >= 0)
then
return -1
end
if(productNum + subNum >=0)
then
return redis.call("INCRBY",KYES[1],0 + subNum)
end
return -2
end
return -3
redis+lua原子性扣除库存
最新推荐文章于 2023-12-23 17:31:27 发布