Class: ActiveSupport::Cache::Strategy::LocalCache::LocalStore

Inherits:
Object
  • Object
show all
Defined in:
activesupport/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 Method Summary collapse

Constructor Details

#initializeLocalStore

Returns a new instance of LocalStore.


32
33
34
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 32

def initialize
  @data = {}
end

Instance Method Details

#clear(options = nil) ⇒ Object


36
37
38
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 36

def clear(options = nil)
  @data.clear
end

#delete_entry(key) ⇒ Object


53
54
55
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 53

def delete_entry(key)
  !!@data.delete(key)
end

#fetch_entry(key) ⇒ Object

:nodoc:


57
58
59
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 57

def fetch_entry(key) # :nodoc:
  @data.fetch(key) { @data[key] = yield }
end

#read_entry(key) ⇒ Object


40
41
42
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 40

def read_entry(key)
  @data[key]
end

#read_multi_entries(keys) ⇒ Object


44
45
46
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 44

def read_multi_entries(keys)
  @data.slice(*keys)
end

#write_entry(key, entry) ⇒ Object


48
49
50
51
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 48

def write_entry(key, entry)
  @data[key] = entry
  true
end