1
0
Fork 0
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:
Jean Boussier 2021-04-13 18:07:12 +02:00
parent 62eb0b9c57
commit c1501e04d0

View file

@ -214,4 +214,18 @@ module LocalCacheBehavior
app = @cache.middleware.new(app) app = @cache.middleware.new(app)
app.call({}) app.call({})
end 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 end