Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions activesupport/lib/active_support/cache/mem_cache_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
raise e
end

require "delegate"
require "active_support/core_ext/enumerable"
require "active_support/core_ext/array/extract_options"

Expand All @@ -33,7 +34,7 @@ def self.supports_cache_versioning?
prepend Strategy::LocalCache

module DupLocalCache
class LocalStore < Strategy::LocalCache::LocalStore
class DupLocalStore < DelegateClass(Strategy::LocalCache::LocalStore)
def write_entry(_key, entry)
if entry.is_a?(Entry)
entry.dup_value!
Expand All @@ -42,12 +43,12 @@ def write_entry(_key, entry)
end

def fetch_entry(key)
entry = @data.fetch(key) do
entry = super do
new_entry = yield
if entry.is_a?(Entry)
new_entry.dup_value!
end
@data[key] = new_entry
new_entry
end
entry = entry.dup

Expand All @@ -59,13 +60,16 @@ def fetch_entry(key)
end
end

def with_local_cache
if ActiveSupport::Cache.format_version == 6.1
use_temporary_local_cache(LocalStore.new) { yield }
else
super
private
def local_cache
if ActiveSupport::Cache.format_version == 6.1
if local_cache = super
DupLocalStore.new(local_cache)
end
else
super
end
end
end
end
prepend DupLocalCache

Expand Down