lib/redis/hash_key.rb in redis-objects-1.3.0 vs lib/redis/hash_key.rb in redis-objects-1.3.1
- old
+ new
@@ -11,11 +11,11 @@
include Redis::Helpers::CoreCommands
attr_reader :key, :options
def initialize(key, *args)
super
- @options[:marshal_keys] ||= {}
+ @options[:marshal_keys] ||= {}
end
# Redis: HSET
def store(field, value)
allow_expiration do
@@ -129,24 +129,24 @@
# Get keys in bulk, takes an array of fields as arguments. Redis: HMGET
def bulk_get(*fields)
hsh = {}
get_fields = *fields.flatten
- get_fields << nil if get_fields.empty?
+ return hsh if get_fields.empty?
res = redis.hmget(key, get_fields)
- fields.each do |k|
+ get_fields.each do |k|
hsh[k] = unmarshal(res.shift, options[:marshal_keys][k])
end
hsh
end
# Get values in bulk, takes an array of keys as arguments.
# Values are returned in a collection in the same order than their keys in *keys Redis: HMGET
def bulk_values(*keys)
get_keys = *keys.flatten
- get_keys << nil if get_keys.empty?
+ return [] if get_keys.empty?
res = redis.hmget(key, get_keys)
- keys.inject([]){|collection, k| collection << unmarshal(res.shift, options[:marshal_keys][k])}
+ get_keys.inject([]){|collection, k| collection << unmarshal(res.shift, options[:marshal_keys][k])}
end
# Increment value by integer at field. Redis: HINCRBY
def incrby(field, by=1)
allow_expiration do