Class: ActiveSupport::Cache::Strategy::LocalCache::LocalStore
- Inherits:
-
ActiveSupport::Cache::Store
- Object
- ActiveSupport::Cache::Store
- ActiveSupport::Cache::Strategy::LocalCache::LocalStore
- Defined in:
- lib/active_support/cache/strategy/local_cache.rb
Overview
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 Attribute Summary
Attributes inherited from ActiveSupport::Cache::Store
Instance Method Summary collapse
- #clear(options = nil) ⇒ Object
- #delete_entry(key, options) ⇒ Object
-
#initialize ⇒ LocalStore
constructor
A new instance of LocalStore.
- #read_entry(key, options) ⇒ Object
-
#synchronize ⇒ Object
Don’t allow synchronizing since it isn’t thread safe,.
- #write_entry(key, value, options) ⇒ Object
Methods inherited from ActiveSupport::Cache::Store
#cleanup, #decrement, #delete, #delete_matched, #exist?, #fetch, #fetch_multi, #increment, instrument, instrument=, #mute, #read, #read_multi, #silence!, #write
Constructor Details
#initialize ⇒ LocalStore
Returns a new instance of LocalStore.
37 38 39 40 |
# File 'lib/active_support/cache/strategy/local_cache.rb', line 37 def initialize super @data = {} end |
Instance Method Details
#clear(options = nil) ⇒ Object
47 48 49 |
# File 'lib/active_support/cache/strategy/local_cache.rb', line 47 def clear( = nil) @data.clear end |
#delete_entry(key, options) ⇒ Object
60 61 62 |
# File 'lib/active_support/cache/strategy/local_cache.rb', line 60 def delete_entry(key, ) !!@data.delete(key) end |
#read_entry(key, options) ⇒ Object
51 52 53 |
# File 'lib/active_support/cache/strategy/local_cache.rb', line 51 def read_entry(key, ) @data[key] end |
#synchronize ⇒ Object
Don’t allow synchronizing since it isn’t thread safe,
43 44 45 |
# File 'lib/active_support/cache/strategy/local_cache.rb', line 43 def synchronize # :nodoc: yield end |
#write_entry(key, value, options) ⇒ Object
55 56 57 58 |
# File 'lib/active_support/cache/strategy/local_cache.rb', line 55 def write_entry(key, value, ) @data[key] = value true end |