Class: Volatile::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/volatile_wtf/cache.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCache

Returns a new instance of Cache.



5
6
7
# File 'lib/volatile_wtf/cache.rb', line 5

def initialize
  @storage = {}
end

Instance Attribute Details

#storageObject (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