forked from redis/redis-rb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdist_redis.rb
43 lines (36 loc) · 809 Bytes
/
dist_redis.rb
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require "redis"
require "redis/distributed"
r = Redis::Distributed.new %w[redis://localhost:6379 redis://localhost:6380 redis://localhost:6381 redis://localhost:6382]
r.flushdb
r['urmom'] = 'urmom'
r['urdad'] = 'urdad'
r['urmom1'] = 'urmom1'
r['urdad1'] = 'urdad1'
r['urmom2'] = 'urmom2'
r['urdad2'] = 'urdad2'
r['urmom3'] = 'urmom3'
r['urdad3'] = 'urdad3'
p r['urmom']
p r['urdad']
p r['urmom1']
p r['urdad1']
p r['urmom2']
p r['urdad2']
p r['urmom3']
p r['urdad3']
r.rpush 'listor', 'foo1'
r.rpush 'listor', 'foo2'
r.rpush 'listor', 'foo3'
r.rpush 'listor', 'foo4'
r.rpush 'listor', 'foo5'
p r.rpop('listor')
p r.rpop('listor')
p r.rpop('listor')
p r.rpop('listor')
p r.rpop('listor')
puts "key distribution:"
r.ring.nodes.each do |node|
p [node.client, node.keys("*")]
end
r.flushdb
p r.keys('*')