Class: ActiveSupport::Cache::MemoryStore

Inherits:
Store show all
Defined in:
lib/active_support/cache/memory_store.rb

Direct Known Subclasses

DRbStore

Instance Method Summary collapse

Methods inherited from Store

#decrement, #fetch, #increment, #threadsafe!

Constructor Details

#initializeMemoryStore

Returns a new instance of MemoryStore.


4
5
6
# File 'lib/active_support/cache/memory_store.rb', line 4

def initialize
  @data = {}
end

Instance Method Details

#clearObject


33
34
35
# File 'lib/active_support/cache/memory_store.rb', line 33

def clear
  @data.clear
end

#delete(name, options = nil) ⇒ Object


18
19
20
21
# File 'lib/active_support/cache/memory_store.rb', line 18

def delete(name, options = nil)
  super
  @data.delete(name)
end

#delete_matched(matcher, options = nil) ⇒ Object


23
24
25
26
# File 'lib/active_support/cache/memory_store.rb', line 23

def delete_matched(matcher, options = nil)
  super
  @data.delete_if { |k,v| k =~ matcher }
end

#exist?(name, options = nil) ⇒ Boolean

Returns:

  • (Boolean)

28
29
30
31
# File 'lib/active_support/cache/memory_store.rb', line 28

def exist?(name,options = nil)
  super
  @data.has_key?(name)
end

#read(name, options = nil) ⇒ Object


8
9
10
11
# File 'lib/active_support/cache/memory_store.rb', line 8

def read(name, options = nil)
  super
  @data[name]
end

#write(name, value, options = nil) ⇒ Object


13
14
15
16
# File 'lib/active_support/cache/memory_store.rb', line 13

def write(name, value, options = nil)
  super
  @data[name] = value
end