Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
skatkov committed Sep 19, 2023
1 parent 50bf1b3 commit 958b97f
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions lib/active_support/cache/database_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def read_entry(key, _options = nil)

def write_entry(key, entry, _options = nil)
record = @model.where(key: key).first_or_initialize
record.update! **entry_attributes(entry)
record.update!(**entry_attributes(entry))
rescue ActiveRecord::RecordNotUnique
# If two servers initialize a new record with the same cache key and try to save it,
# the saves will race. We do not need to ensure a specific save wins, but we do need to ensure
Expand All @@ -120,15 +120,7 @@ def delete_entry(key, _options = nil)
end

def write_multi_entries(hash, **_options)
entries = hash.map do |key, entry|
expires_at = Time.zone.at(entry.expires_at) if entry.expires_at

{
key: key,
created_at: Time.zone.now,
**entry_attributes(entry),
}
end
entries = hash.map { |key, entry| { key: key, created_at: Time.zone.now, **entry_attributes(entry) }}

# In rails 7, we can use update_only not to do anything. But for the sakes of compatibility, we don't use any additional parameters.
@model.upsert_all(entries)
Expand Down

0 comments on commit 958b97f

Please sign in to comment.