local currentValue = tonumber(redis.call('GET', KEYS[1]))
if not currentValue or (ARGV[1] == 'smaller' and tonumber(ARGV[2]) < currentValue) or (ARGV[1] == 'larger' and tonumber(ARGV[2]) > currentValue) then
redis.call('SET', KEYS[1], ARGV[2])
return true
else
return false
end
1条答案
按热度按时间smdnsysy1#
没有一个简单的命令来实现这一点,但是你可以尝试使用一个不需要多个客户端命令的Lua脚本,比如:
字符串