Open
Description
I noticed that the python redis library will raise an exception when you are watching any key.
In my opinion, think is quite useful when you are inside loops and using watch
method.
Here is an example:
while Time.now.to_i < threshold do
begin
client.watch("market:", buyer) do
price = client.zscore("market:", item).to_i
funds = client.hget(buyer, 'funds')
if price != seller_price || price > funds
client.unwatch
break
end
client.multi do |multi|
multi.hincrby(seller, 'funds', price)
multi.hincrby(buyer, 'funds', price * -1)
multi.sadd(inventory, itemid)
multi.zrem('market:', item)
end
break
end
rescue Redis::WatchError
next
end
end
I would like to know if you think it something useful and if so I do not mind working on a PR to add it
Metadata
Metadata
Assignees
Labels
No labels