Class: MMS::Cache
Instance Attribute Summary collapse
-
#storage ⇒ Object
Returns the value of attribute storage.
Instance Method Summary collapse
- #clear ⇒ Object
- #delete(key) ⇒ Object
- #get(key) ⇒ Object
-
#initialize ⇒ Cache
constructor
A new instance of Cache.
- #set(key, value) ⇒ Object
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
#clear ⇒ Object
32 33 34 |
# File 'lib/mms/cache.rb', line 32 def clear initialize end |
#delete(key) ⇒ Object
28 29 30 |
# File 'lib/mms/cache.rb', line 28 def delete(key) @storage.delete key unless @storage[key].nil? end |
#get(key) ⇒ Object
23 24 25 |
# File 'lib/mms/cache.rb', line 23 def get(key) @storage[key].nil? ? nil : @storage[key] end |
#set(key, value) ⇒ Object
17 18 19 |
# File 'lib/mms/cache.rb', line 17 def set(key, value) @storage[key] = value end |