Class: Volatile::Cache
- Inherits:
-
Object
- Object
- Volatile::Cache
- Defined in:
- lib/volatile_wtf/cache.rb
Instance Attribute Summary collapse
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
- #fetch(key, &block) ⇒ Object
-
#initialize ⇒ Cache
constructor
A new instance of Cache.
- #save(key, value) ⇒ Object
Constructor Details
#initialize ⇒ Cache
Returns a new instance of Cache.
5 6 7 |
# File 'lib/volatile_wtf/cache.rb', line 5 def initialize @storage = {} end |
Instance Attribute Details
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
3 4 5 |
# File 'lib/volatile_wtf/cache.rb', line 3 def storage @storage end |
Instance Method Details
#fetch(key, &block) ⇒ Object
13 14 15 |
# File 'lib/volatile_wtf/cache.rb', line 13 def fetch(key, &block) @storage.fetch(key, &block) end |
#save(key, value) ⇒ Object
9 10 11 |
# File 'lib/volatile_wtf/cache.rb', line 9 def save(key, value) @storage[key] = value end |