Class: Rotten::Cache

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Cache

Returns a new instance of Cache.



10
11
12
# File 'lib/rotten/cache.rb', line 10

def initialize options={}
  @store = options.delete(:store) || SimpleCache.new(options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



24
25
26
# File 'lib/rotten/cache.rb', line 24

def method_missing sym, *args, &block
  @store.send sym, *args, &block
end

Instance Attribute Details

#storeObject (readonly)

Returns the value of attribute store.



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

def store
  @store
end

Instance Method Details

#read(key) ⇒ Object Also known as: get



14
15
16
# File 'lib/rotten/cache.rb', line 14

def read key
  @store.read key
end

#write(key, value) ⇒ Object Also known as: set



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

def write key, value
  @store.write key, value
end