#!/usr/bin/env ruby require 'redis' redis_master = Redis.new(host: "localhost", port: 6379) redis_slave = Redis.new(host: "172.31.8.119", port: 12322) puts "###################################################################################" puts "# Setting" begin # Check to see connection is valid before pipelining redis_master.ping # Pipeline for efficiency redis_master.pipelined do (1..100).each do |x| puts "adding key #{x} => mague " redis_master.set("#{x}", "mague") end end rescue Exception => e puts "ERROR: master #{e.message}" exit! 1 end puts "###################################################################################" puts "# Fetching" begin (1..100).reverse_each do |x| puts "Fetching: #{x} => #{redis_slave.get(x)}" end rescue Exception => e puts "ERROR: slave: #{e}" exit! 1 end