diff options
author | Steve Kemp <steve@steve.org.uk> | 2016-01-18 14:16:07 +0200 |
---|---|---|
committer | Steve Kemp <steve@steve.org.uk> | 2016-01-18 14:16:07 +0200 |
commit | c6f2c6f924e6b263be5a3ba4a4eb7049f27544d3 (patch) | |
tree | e023f6bbef8a2ecf8829a0d0ab5214b902266bc7 /queue/zset/add.rb | |
parent | fbd4e3bf99afbc80012d6dc029be19e1bd8e6890 (diff) |
Removed queue-examples.
These are no longer required now we're sure we understand the process
of adding jobs to the queue without duplication.
Diffstat (limited to 'queue/zset/add.rb')
-rwxr-xr-x | queue/zset/add.rb | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/queue/zset/add.rb b/queue/zset/add.rb deleted file mode 100755 index 2d9f27a..0000000 --- a/queue/zset/add.rb +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/ruby -# -# Add the same three tests over and over again. -# -# -require "redis" - -@redis = Redis.new(:host => "127.0.0.1") - -x = [] - -# -# Queue loads of tests -# -(1..10).to_a.each do |i| - x.push( "test #{i}" ) -end - -loop do - x.each do |test| - @redis.watch('zset') - - print "adding #{test}" - - # - # This is run in a loop, as we have to wait until both - # - # (a) the score is missing - # (b) the zadd function succeeds - # - loop do - # - # Print a dot for each go through the loop - # - print "." - - # - # Only update if no score is set - # - if !@redis.zscore("zset", test) - - # - # If MULTI returns nil, the transaction failed, so we need to try - # again. - # - break unless @redis.multi do |r| - @redis.zadd('zset', Time.now.to_f, test) - end.nil? - - end - - # - # This could be tighter.. - # - sleep 0.1 - end - - print "\n" - - # - # Do we need to unwatch here? - # - @redis.unwatch - end -end |