Class: ActiveSupport::Cache::Strategy::LocalCache::LocalStore
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activesupport/lib/active_support/cache/strategy/local_cache.rb |
Overview
Local Cache Store
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.
Class Method Summary
- .new ⇒ LocalStore constructor
Instance Method Summary
Constructor Details
.new ⇒ LocalStore
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 36
def initialize @data = {} end
Instance Method Details
#clear(options = nil)
[ GitHub ]# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 40
def clear( = nil) @data.clear end
#delete_entry(key)
[ GitHub ]# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 57
def delete_entry(key) !!@data.delete(key) end
#fetch_entry(key)
This method is for internal use only.
[ GitHub ]
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 61
def fetch_entry(key) # :nodoc: @data.fetch(key) { @data[key] = yield } end
#read_entry(key)
[ GitHub ]# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 44
def read_entry(key) @data[key] end
#read_multi_entries(keys)
[ GitHub ]# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 48
def read_multi_entries(keys) @data.slice(*keys) end
#write_entry(key, entry)
[ GitHub ]# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 52
def write_entry(key, entry) @data[key] = entry true end