Permalink
Browse files

Fix example for Redis::Distributed.

  • Loading branch information...
1 parent e70dd88 commit 4873f494185b707cb1c50f684a250decfd55d368 @djanowski djanowski committed Apr 16, 2010
Showing with 19 additions and 17 deletions.
  1. +19 −17 examples/dist_redis.rb
View
@@ -1,8 +1,10 @@
-require 'rubygems'
-require 'redis'
-require 'redis/dist_redis'
+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 = DistRedis.new :hosts => %w[localhost:6379 localhost:6380 localhost:6381 localhost:6382]
r['urmom'] = 'urmom'
r['urdad'] = 'urdad'
r['urmom1'] = 'urmom1'
@@ -20,22 +22,22 @@
p r['urmom3']
p r['urdad3']
-r.push_tail 'listor', 'foo1'
-r.push_tail 'listor', 'foo2'
-r.push_tail 'listor', 'foo3'
-r.push_tail 'listor', 'foo4'
-r.push_tail 'listor', 'foo5'
+r.rpush 'listor', 'foo1'
+r.rpush 'listor', 'foo2'
+r.rpush 'listor', 'foo3'
+r.rpush 'listor', 'foo4'
+r.rpush 'listor', 'foo5'
-p r.pop_tail('listor')
-p r.pop_tail('listor')
-p r.pop_tail('listor')
-p r.pop_tail('listor')
-p r.pop_tail('listor')
+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 |red|
- p [red.server, red.keys("*")]
+r.ring.nodes.each do |node|
+ p [node.client, node.keys("*")]
end
-r.delete_cloud!
+r.flushdb
p r.keys('*')

0 comments on commit 4873f49

Please sign in to comment.