简单的内存支持缓存。此缓存不是线程安全的,并且仅用作单个线程的临时内存缓存。
来源:显示 | GitHub
# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 36 def initialize @data = {} end
# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 40 def clear(options = nil) @data.clear end
# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 57 def delete_entry(key) !!@data.delete(key) end
# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 44 def read_entry(key) @data[key] end
# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 48 def read_multi_entries(keys) @data.slice(*keys) end
# File activesupport/lib/active_support/cache/strategy/local_cache.rb, line 52 def write_entry(key, entry) @data[key] = entry true end