Commit 8d628078 authored by Rajko Albrecht's avatar Rajko Albrecht

Start implementing cas_multi

parent af6b1932
......@@ -16,8 +16,14 @@ class Redis
end
end
def cas_multi keys, ttl=nil
def cas_multi *keys
options = extract_options keys
return if keys.empty?
watch keys do
values = read_multi keys.merge(options)
valuehash = yield values
end
end
def read_multi *keys
......@@ -32,6 +38,14 @@ class Redis
def return_value result
result.is_a?(Array) && result[0] == 'OK'
end
def extract_options array
if array.last.is_a?(Hash) && array.last.instance_of?(Hash)
array.pop
else
{}
end
end
end
end
......
......@@ -33,6 +33,10 @@ describe Redis::Store::StoreWithCas do
assert_equal 'baz', @store.get('foo')
end
def test_cas_multi_with_empty_set
refute @store.cas_multi { |_hash| flunk }
end
def test_read_multi
@store.set('k1','m1')
......
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