Created
April 22, 2013 18:52
-
-
Save squarism/5437513 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: UTF-8 | |
# hey when is redis 2.8 coming out with clustering? | |
# I DON'T KNOW SO LET'S DO THIS HAPPY HORSE HOCKEY UNTIL THEN | |
require 'redis' | |
require 'redis/distributed' | |
r = Redis::Distributed.new [ | |
'redis://box1:6379', | |
'redis://box2:6379', | |
'redis://box3:6379' | |
] | |
r.flushdb | |
peeps = ['Alfred', 'Barry', 'Chet', 'Dave', 'Eli', 'Francine', 'Gertrude', | |
'Hermy', 'Igor', 'Jasmine', 'KC', 'Lisa', 'Marice', 'Nick', 'Olivia', | |
'Poe', 'Quincy', 'Rose', 'Sambo', 'Tia', 'Ulver', 'Veronica', 'Walter', | |
'Yolanda', 'Ziggy' | |
] | |
peeps.each do |p| | |
r.set p, 'present' | |
end | |
food = [ 'apple', 'banana', 'carrot', 'danish', 'egg', 'rose', 'rosé' ] | |
food.each do |f| | |
r.set f, 'tasty' | |
end | |
# box1 | |
# redis 127.0.0.1:6379> keys '*os*' | |
# 1) "rose" | |
# 2) "Rose" | |
# | |
# box2 | |
# redis 127.0.0.1:6379> keys '*os*' | |
# (empty list or set) | |
# | |
# box3 | |
# redis 127.0.0.1:6379> keys '*os*' | |
# 1) "ros\xc3\xa9" | |
# Oh no! This is a problem! Our keys are all over the place. | |
# When we remove or add a host this distribution will change. | |
# Boo! That's where something like https://github.com/yankov/redis-migrator | |
# comes into play. Or wait for redis-cluster in 2.8 or 3.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment