local tag_hp = tonumber(redis.call('hget', KEYS[1],'hp')) local bank_hp = tonumber(redis.call('hget', KEYS[2],KEYS[3])) bank_hp = not bank_hp and 0 or bank_hp local hp = tonumber(ARGV[1]) local opt = tonumber(ARGV[2]) if opt==0 then if bank_hp < hp then return 3 end bank_hp = redis.call('hincrBy',KEYS[2],KEYS[3],-hp) tag_hp = redis.call('hincrBy',KEYS[1],'hp',hp) else if tag_hp < hp then return 4 end bank_hp = redis.call('hincrBy',KEYS[2],KEYS[3],hp) tag_hp = redis.call('hincrBy',KEYS[1],'hp',-hp) end return {tag_hp,bank_hp}