Skip to content

Commit

Permalink
Merge pull request #64 from fauna/rescue_ConnectionDataExists
Browse files Browse the repository at this point in the history
Don't raise ConnectionDataExists from cas() in the Rails adaptor.
  • Loading branch information
evan committed Sep 15, 2011
2 parents ffde230 + 8ea85e8 commit 4c891bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
v1.3.1 rescue ConnectionDataExists for cas because Rails shim over Memcached is not supposed to raise anything for legacy reasons

v1.3. Improvements to BSD support; add Memcached#touch method (avsej).

v1.2.7.1 Retry SomeErrorsWereReported exception
Expand Down
2 changes: 1 addition & 1 deletion lib/memcached/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def exist?(key, options = {})
def cas(key, ttl=@default_ttl, raw=false, &block)
super(key, ttl, !raw, &block)
true
rescue NotFound
rescue NotFound, ConnectionDataExists
false
end

Expand Down
8 changes: 5 additions & 3 deletions test/unit/rails_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,16 @@ def test_cas
assert_nil cache.get(key)
assert_nil @called

# Conflicting set
# Conflicting set after a gets
cache.set key, @value
assert_raises(Memcached::ConnectionDataExists) do
cache.cas(key) do |current|
assert_nothing_raised do
result = cache.cas(key) do |current|
cache.set key, value2
current
end
assert_equal result, false
end
assert_equal value2, cache.get(key)
end

def test_get_missing
Expand Down

0 comments on commit 4c891bd

Please sign in to comment.