summaryrefslogtreecommitdiff
path: root/queue/zset/add.rb
blob: c75bcd6369c76a0bc02a33b8aa3dc79e922b3597 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/ruby
#
# Add the same three tests over and over again.
#
#
require "redis"

@redis = Redis.new(:host => "127.0.0.1")


x = []

x.push( "test 1" )
x.push( "test 2" )
x.push( "test 3" )


for i in 0 .. 10 
    x.each do |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