提交 accd4926 编写于 作者: M Murray Steele

Fix FileStore#cleanup to no longer rely on missing each_key method

上级 db2c4abc
* Fix ActiveSupport::Cache::FileStore#cleanup to no longer rely on missing each_key method.
*Murray Steele*
* Ensure that autoloaded constants in all-caps nestings are marked as
autoloaded.
......
......@@ -33,7 +33,8 @@ def clear(options = nil)
# Premptively iterates through all stored keys and removes the ones which have expired.
def cleanup(options = nil)
options = merged_options(options)
each_key(options) do |key|
search_dir(cache_path) do |fname|
key = file_path_key(fname)
entry = read_entry(key, options)
delete_entry(key, options) if entry && entry.expired?
end
......
......@@ -709,6 +709,18 @@ def test_log_exception_when_cache_read_fails
@cache.send(:read_entry, "winston", {})
assert @buffer.string.present?
end
def test_cleanup_removes_all_expired_entries
time = Time.now
@cache.write('foo', 'bar', expires_in: 10)
@cache.write('baz', 'qux')
@cache.write('quux', 'corge', expires_in: 20)
Time.stubs(:now).returns(time + 15)
@cache.cleanup
assert_not @cache.exist?('foo')
assert @cache.exist?('baz')
assert @cache.exist?('quux')
end
end
class MemoryStoreTest < ActiveSupport::TestCase
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册