Skip to content

Instantly share code, notes, and snippets.

@xiangzhuyuan
Created January 12, 2015 15:36
Show Gist options
  • Save xiangzhuyuan/2f3a2e84759e814e169f to your computer and use it in GitHub Desktop.
Save xiangzhuyuan/2f3a2e84759e814e169f to your computer and use it in GitHub Desktop.
require 'date'
require 'redis'
$redis = Redis.new({:host => "localhost", :port => "6379"})
#p $redis.ping
$redis.flushall
%w{my sg es de th tw gb gs id at}.each do |item|
i = 0
10.downto 1 do
timestamp = DateTime.now.new_offset(0).strftime('%Y%m%d%H%M%s')
tag_name = 'tag_'+timestamp
i +=1
#$redis.lpush(item + "_mylist_"+timestamp, item+ "_i_"+ i.to_s)
$redis.lpush item, item +"_"+tag_name
$redis.hmset item+"_"+tag_name, 'push_code', 'ok', 'add_env', 'ok', 'mapping', 'ok'
end
end
p $redis.keys
# $redis.keys.each do |country|
# ($redis.lrange country, 0, -1).each do
# |item|
# p item
# end
# end
#p $redis.info
#get the first item
#p $redis.lrange 'mylist1', 0, 0
p '*'*10
%w{my sg es de th tw gb gs id at}.each do |item|
($redis.lrange item, 0, -1).each do
|item|
p item
p $redis.hget item, 'push_code'
end
p '*'*10
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment