Class: ActiveSupport::Cache::Strategy::LocalCache::LocalStore
- 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.
Instance Method Summary collapse
- #clear(options = nil) ⇒ Object
- #delete_entry(key) ⇒ Object
- 
  
    
      #fetch_entry(key)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    :nodoc:. 
- 
  
    
      #initialize  ⇒ LocalStore 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of LocalStore. 
- #read_entry(key) ⇒ Object
- #read_multi_entries(keys) ⇒ Object
- #write_entry(key, entry) ⇒ Object
Constructor Details
#initialize ⇒ LocalStore
Returns a new instance of LocalStore.
| 36 37 38 | # File 'activesupport/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 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 40 def clear( = nil) @data.clear end | 
#delete_entry(key) ⇒ Object
| 57 58 59 | # File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 57 def delete_entry(key) !!@data.delete(key) end | 
#fetch_entry(key) ⇒ Object
:nodoc:
| 61 62 63 | # 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) ⇒ Object
| 44 45 46 | # File 'activesupport/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 'activesupport/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 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 52 def write_entry(key, entry) @data[key] = entry true end |