Class: CanTango::Cache::HashCache

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/cantango/cache/hash_cache.rb', line 6

def options
  @options
end

Instance Method Details

#cacheObject



27
28
29
# File 'lib/cantango/cache/hash_cache.rb', line 27

def cache
  @cache ||= {}
end

#configure_with(options = {}) ⇒ Object



8
9
10
# File 'lib/cantango/cache/hash_cache.rb', line 8

def configure_with options = {}
  @options ||= options
end

#delete(key) ⇒ Object



22
23
24
25
# File 'lib/cantango/cache/hash_cache.rb', line 22

def delete key
  raise "no key" if key.nil?
  cache[key].delete if cache[key]
end

#load!(key) ⇒ Object



12
13
14
15
# File 'lib/cantango/cache/hash_cache.rb', line 12

def load! key
  raise "no key" if key.nil?
  cache[key]
end

#save!(key, rules) ⇒ Object



17
18
19
20
# File 'lib/cantango/cache/hash_cache.rb', line 17

def save! key, rules
  raise "no key" if key.nil?
  cache[key] = rules
end

#typeObject



31
32
33
# File 'lib/cantango/cache/hash_cache.rb', line 31

def type
  :memory
end