mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add a test case for race_condition_ttl with local_cache enabled
This commit is contained in:
parent
62eb0b9c57
commit
c1501e04d0
1 changed files with 14 additions and 0 deletions
|
@ -214,4 +214,18 @@ module LocalCacheBehavior
|
|||
app = @cache.middleware.new(app)
|
||||
app.call({})
|
||||
end
|
||||
|
||||
def test_local_race_condition_protection
|
||||
@cache.with_local_cache do
|
||||
time = Time.now
|
||||
@cache.write("foo", "bar", expires_in: 60)
|
||||
Time.stub(:now, time + 61) do
|
||||
result = @cache.fetch("foo", race_condition_ttl: 10) do
|
||||
assert_equal "bar", @cache.read("foo")
|
||||
"baz"
|
||||
end
|
||||
assert_equal "baz", result
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue