Commit c3c066ff authored by Rajko Albrecht's avatar Rajko Albrecht

cas/cas_multi basicly finished

parent 95303b07
......@@ -23,10 +23,13 @@ class Redis
values = read_multi(*keys)
options = extract_options keys
valuehash = yield values
ires = multi do |multi|
valuehash.map do |name,value|
result = {}
v = valuehash.map do |name,value|
ires = multi do |multi|
multi.set(name,value,options) if values.key?(name)
end
result[name] = value if return_value(ires)
end
true
end
......
......@@ -3,7 +3,6 @@ require 'test_helper'
describe Redis::Store::StoreWithCas do
def setup
@store = Redis::Store::StoreWithCas.new :namespace => 'storetest'
@client = @store.instance_variable_get(:@client)
end
def teardown
......@@ -77,4 +76,27 @@ describe Redis::Store::StoreWithCas do
assert_equal 'baz', @store.get('foo')
end
def test_cas_multi_with_partial_update
@store.set('foo', 'bar')
@store.set('fud', 'biz')
assert(@store.cas_multi('foo', 'fud') do |hash|
assert_equal({ "foo" => "bar", "fud" => "biz" }, hash)
{ "foo" => "baz" }
end)
assert_equal({ "foo" => "baz", "fud" => "biz" }, @store.read_multi('foo', 'fud'))
end
def test_cas_multi_with_partial_conflict
@store.set('foo', 'bar')
@store.set('fud', 'biz')
result = @store.cas_multi('foo', 'fud') do |hash|
assert_equal({ "foo" => "bar", "fud" => "biz" }, hash)
@store.set('foo', 'bad')
{ "foo" => "baz", "fud" => "buz" }
end
assert result
assert_equal({ "foo" => "bad", "fud" => "buz" }, @store.read_multi('foo', 'fud'))
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