Commit af6b1932 authored by Rajko Albrecht's avatar Rajko Albrecht

add a read_multi which returns result as hash

parent 9139ffe6
......@@ -20,6 +20,13 @@ class Redis
end
def read_multi *keys
values = mget(*keys)
resulthash = {}
keys.zip(values) { |a,b| resulthash[a.to_s] = b}
resulthash
end
private
def return_value result
......
......@@ -33,4 +33,10 @@ describe Redis::Store::StoreWithCas do
assert_equal 'baz', @store.get('foo')
end
def test_read_multi
@store.set('k1','m1')
@store.set('k2','m2')
assert_equal({"k1" => "m1","k2" => "m2"},@store.read_multi("k1","k2"))
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment