Sha256: fb07d1739308566f384155662e20b4835f8c92238ad47da63ac4fd224e85d8fd
Contents?: true
Size: 719 Bytes
Versions: 1
Compression:
Stored size: 719 Bytes
Contents
require "metacrunch/redis" module Metacrunch class Redis::Writer def initialize(redis_connection_or_url, options = {}) @save_on_close = options.delete(:save_on_close) || true @key = options.delete(:key) || :key @redis = if redis_connection_or_url.is_a?(String) ::Redis.new(url: redis_connection_or_url) else redis_connection_or_url end end def write(data) key = data[@key] raise ArgumentError, "No key found in data. Tried '#{@key}' but didn't found a value." unless key @redis.set(key.to_s, data.to_json) end def close if @redis @redis.bgsave if @save_on_close @redis.close end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
metacrunch-3.1.4 | lib/metacrunch/redis/writer.rb |