Simple memory backed cache. This cache is not thread safe and is intended only for serving as a temporary memory cache for a single thread.
Methods
Class Public methods
new()
📝 Source code
# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 38
def initialize
super
@data = {}
end
🔎 See on GitHub
Instance Public methods
clear(options = nil)
📝 Source code
# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 48
def clear(options = nil)
@data.clear
end
🔎 See on GitHub
delete_entry(key, **options)
📝 Source code
# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 73
def delete_entry(key, **options)
!!@data.delete(key)
end
🔎 See on GitHub
read_entry(key, **options)
📝 Source code
# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 52
def read_entry(key, **options)
@data[key]
end
🔎 See on GitHub
read_multi_entries(keys, **options)
📝 Source code
# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 56
def read_multi_entries(keys, **options)
values = {}
keys.each do |name|
entry = read_entry(name, **options)
values[name] = entry.value if entry
end
values
end
🔎 See on GitHub
write_entry(key, entry, **options)
📝 Source code
# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 67
def write_entry(key, entry, **options)
entry.dup_value!
@data[key] = entry
true
end
🔎 See on GitHub