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

Inherits:
ActiveSupport::Cache::Store 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 Attribute Summary

Attributes inherited from ActiveSupport::Cache::Store

#options, #silence

Instance Method Summary (collapse)

Methods inherited from ActiveSupport::Cache::Store

#cleanup, #decrement, #delete, #delete_matched, #exist?, #fetch, #increment, instrument, instrument=, #mute, #read, #read_multi, #silence!, #write

Constructor Details

- (LocalStore) initialize

A new instance of LocalStore



14
15
16
17
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 14

def initialize
  super
  @data = {}
end

Instance Method Details

- (Object) clear(options = nil)



24
25
26
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 24

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

- (Object) delete_entry(key, options)



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

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

- (Object) read_entry(key, options)



28
29
30
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 28

def read_entry(key, options)
  @data[key]
end

- (Object) synchronize

Don't allow synchronizing since it isn't thread safe,



20
21
22
# File 'activesupport/lib/active_support/cache/strategy/local_cache.rb', line 20

def synchronize # :nodoc:
  yield
end

- (Object) write_entry(key, value, options)



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

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