Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix ArgumentError in ActiveSupport::Cache::CacheStore.read_multi #2393

Merged
merged 1 commit into from

2 participants

Brian Durand Santiago Pastorino
Brian Durand

There is a call in activesupport-3.0.9/lib/active_support/cache.rb#read_multi to delete entry (on or about line 348). This breaks the call in both 3.0.x and 3.1 branches with any cache other than MemCacheStore.. The change is trivial so the code is below. Also added a test case.

  if entry.expired?
    delete_entry(key)
  else
    results[name] = entry.value
  end

Unfortunately, the delete_entry method takes two arguments. It should be:

  if entry.expired?
    delete_entry(key, options)
  else
    results[name] = entry.value
  end
Santiago Pastorino spastorino merged commit 6e701e8 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 1, 2011
  1. Brian Durand
This page is out of date. Refresh to see the latest.
2  activesupport/lib/active_support/cache.rb
View
@@ -347,7 +347,7 @@ def read_multi(*names)
entry = read_entry(key, options)
if entry
if entry.expired?
- delete_entry(key)
+ delete_entry(key, options)
else
results[name] = entry.value
end
8 activesupport/test/caching_test.rb
View
@@ -199,6 +199,14 @@ def test_read_multi
@cache.write('fud', 'biz')
assert_equal({"foo" => "bar", "fu" => "baz"}, @cache.read_multi('foo', 'fu'))
end
+
+ def test_read_multi_with_expires
+ @cache.write('foo', 'bar', :expires_in => 0.001)
+ @cache.write('fu', 'baz')
+ @cache.write('fud', 'biz')
+ sleep(0.002)
+ assert_equal({"fu" => "baz"}, @cache.read_multi('foo', 'fu'))
+ end
def test_read_and_write_compressed_small_data
@cache.write('foo', 'bar', :compress => true)
Something went wrong with that request. Please try again.