From ddd8335d24b2e59aaf7eec64bbef3d4d95b89733 Mon Sep 17 00:00:00 2001 From: James Lawrie Date: Sun, 20 Dec 2015 09:58:56 +0000 Subject: Fixing test suite as per lodge post --- queue/zset/add.rb | 9 +++++++-- queue/zset/run.rb | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/queue/zset/add.rb b/queue/zset/add.rb index 2c778a4..c75bcd6 100755 --- a/queue/zset/add.rb +++ b/queue/zset/add.rb @@ -17,8 +17,13 @@ x.push( "test 3" ) for i in 0 .. 10 x.each do |test| - puts "adding #{test}" - @redis.zadd('zset', Time.now.to_i, test) + @redis.watch('zset') + if (!(@redis.zscore("zset", test))) + res = @redis.multi do |r| + r.zadd('zset', Time.now.to_f * 10000000, test) + end + end + @redis.unwatch end sleep 1 end diff --git a/queue/zset/run.rb b/queue/zset/run.rb index 2fc861c..b6990ff 100755 --- a/queue/zset/run.rb +++ b/queue/zset/run.rb @@ -10,7 +10,7 @@ def fetch(timeout = 1) job = nil loop do - job = @redis.ZREVRANGE('zset', '0', '0') + job = @redis.ZRANGE('zset', '0', '0') if !job.empty? # We only have one entry in our array -- cgit v1.2.1