Sha256: 47dd63cac5402a7a347815c9c16fb6a9fc2ed5be11f343a210dd59222c7f4201
Contents?: true
Size: 934 Bytes
Versions: 1
Compression:
Stored size: 934 Bytes
Contents
module RedisDatapump class Importer IMPORTER_MAP = { 'string' => proc {|client, key, value| client.set(key, value)}, 'hash' => proc {|client, key, values| client.hmset(key, values)}, 'set' => proc {|client, key, members| client.sadd(key, members)}, 'list' => proc {|client, key, values| client.rpush key, values }, 'zset' => proc {|client, key| client.zrange(key, 0, -1, :with_scores => true) }, } def initialize opts @options = opts Validator.new(@options).validate! end def import content IMPORTER_MAP[content['type']].call(redis_client, content['key'], content['value']) @redis_client.pexpire(content['key'], content['ttl']) if content['ttl'] != -1 end def redis_client return @redis_client if @redis_client url = "#{@options[:redis_url]}/#{@options[:redis_database]}" @redis_client = Redis.connect(url: url) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
redis-datapump-0.1.0.alpha1 | lib/redis-datapump/importer.rb |