Class: ActiveSupport::Cache::Strategy::LocalCache::LocalStore
- Inherits:
-
Object
- Object
- ActiveSupport::Cache::Strategy::LocalCache::LocalStore
show all
- Defined in:
- 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.
Instance Method Summary
collapse
Constructor Details
Returns a new instance of LocalStore.
36
37
38
|
# File 'lib/active_support/cache/strategy/local_cache.rb', line 36
def initialize
@data = {}
end
|
Instance Method Details
#clear(options = nil) ⇒ Object
40
41
42
|
# File 'lib/active_support/cache/strategy/local_cache.rb', line 40
def clear(options = nil)
@data.clear
end
|
#delete_entry(key) ⇒ Object
57
58
59
|
# File 'lib/active_support/cache/strategy/local_cache.rb', line 57
def delete_entry(key)
!!@data.delete(key)
end
|
#fetch_entry(key) ⇒ Object
61
62
63
|
# File 'lib/active_support/cache/strategy/local_cache.rb', line 61
def fetch_entry(key) @data.fetch(key) { @data[key] = yield }
end
|
#read_entry(key) ⇒ Object
44
45
46
|
# File 'lib/active_support/cache/strategy/local_cache.rb', line 44
def read_entry(key)
@data[key]
end
|
#read_multi_entries(keys) ⇒ Object
48
49
50
|
# File 'lib/active_support/cache/strategy/local_cache.rb', line 48
def read_multi_entries(keys)
@data.slice(*keys)
end
|
#write_entry(key, entry) ⇒ Object
52
53
54
55
|
# File 'lib/active_support/cache/strategy/local_cache.rb', line 52
def write_entry(key, entry)
@data[key] = entry
true
end
|