lib/pupa/processor/document_store/redis_store.rb in pupa-0.0.11 vs lib/pupa/processor/document_store/redis_store.rb in pupa-0.0.12
- old
+ new
@@ -40,45 +40,45 @@
# Returns, as JSON, the value of the given key.
#
# @param [String] name a key
# @return [Hash] the value of the given key
def read(name)
- MultiJson.load(@redis.get(name))
+ Oj.load(@redis.get(name))
end
# Returns, as JSON, the values of the given keys.
#
# @param [String] names keys
# @return [Array<Hash>] the values of the given keys
def read_multi(names)
- @redis.mget(*names).map{|value| MultiJson.load(value)}
+ @redis.mget(*names).map{|value| Oj.load(value)}
end
# Writes, as JSON, the value to a key.
#
# @param [String] name a key
# @param [Hash] value a value
def write(name, value)
- @redis.set(name, MultiJson.dump(value))
+ @redis.set(name, Oj.dump(value, mode: :compat, time_format: :ruby))
end
# Writes, as JSON, the value to a key, unless the key exists.
#
# @param [String] name a key
# @param [Hash] value a value
# @return [Boolean] whether the key was set
def write_unless_exists(name, value)
- @redis.setnx(name, MultiJson.dump(value))
+ @redis.setnx(name, Oj.dump(value, mode: :compat, time_format: :ruby))
end
# Writes, as JSON, the values to keys.
#
# @param [Hash] pairs key-value pairs
def write_multi(pairs)
args = []
pairs.each do |key,value|
args << key
- args << MultiJson.dump(value)
+ args << Oj.dump(value, mode: :compat, time_format: :ruby)
end
@redis.mset(*args)
end
# Delete a key.