Skip to content

Commit

Permalink
Merge pull request #49974 from fatkodima/fix-redis-write_multi-with-e…
Browse files Browse the repository at this point in the history
…xpires_in

Fix `RedisCacheStore#write_multi` with `:expires_in`

(cherry picked from commit c36f877)
  • Loading branch information
jonathanhefner committed Nov 8, 2023
1 parent 8a34a93 commit f6987c4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions activesupport/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Fix `:expires_in` option for `RedisCacheStore#write_multi`.

*fatkodima*

* Fix deserialization of non-string "purpose" field in Message serializer

*Jacopo Beschi*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def delete_multi_entries(entries, **_options)
end

# Nonstandard store provider API to write multiple values at once.
def write_multi_entries(entries, expires_in: nil, race_condition_ttl: nil, **options)
def write_multi_entries(entries, **options)
return if entries.empty?

failsafe :write_multi_entries do
Expand Down
9 changes: 9 additions & 0 deletions activesupport/test/cache/behaviors/cache_store_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ def test_write_multi_empty_hash
assert @cache.write_multi({})
end

def test_write_multi_expires_in
key = SecureRandom.uuid
@cache.write_multi({ key => 1 }, expires_in: 10)

travel(11.seconds) do
assert_nil @cache.read(key)
end
end

def test_fetch_multi
key = SecureRandom.uuid
other_key = SecureRandom.uuid
Expand Down

0 comments on commit f6987c4

Please sign in to comment.