lib/redis/hash_key.rb in redis-objects-0.5.3 vs lib/redis/hash_key.rb in redis-objects-0.6.0
- old
+ new
@@ -133,9 +133,16 @@
hsh[k] = from_redis(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)
+ res = redis.hmget(key, *keys.flatten)
+ keys.inject([]){|collection, k| collection << from_redis(res.shift)}
+ end
+
# Increment value by integer at field. Redis: HINCRBY
def incrby(field, val = 1)
ret = redis.hincrby(key, field, val)
unless ret.is_a? Array
ret.to_i