Class: MMS::Cache

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/mms/cache.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Cache

Returns a new instance of Cache.



11
12
13
# File 'lib/mms/cache.rb', line 11

def initialize
  @storage = Hash.new {|hash, key| hash[key] = nil }
end

Instance Attribute Details

#storage ⇒ Object

Returns the value of attribute storage.



9
10
11
# File 'lib/mms/cache.rb', line 9

def storage
  @storage
end

Instance Method Details

#delete(key) ⇒ Object



23
24
25
# File 'lib/mms/cache.rb', line 23

def delete(key)
  @storage.delete key unless @storage[key].nil?
end

#get(key) ⇒ Object



19
20
21
# File 'lib/mms/cache.rb', line 19

def get(key)
  @storage[key].nil? ? nil : @storage[key]
end

#set(key, value) ⇒ Object



15
16
17
# File 'lib/mms/cache.rb', line 15

def set(key, value)
  @storage[key] = value
end