Module: Howitzer::Cache
- Defined in:
- lib/howitzer/cache.rb
Overview
Data can be stored in memory using this class
Constant Summary collapse
- SPECIAL_NS_LIST =
:nodoc:
[:cloud].freeze
Class Attribute Summary collapse
-
.data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
-
.clear_all_ns(exception_list = SPECIAL_NS_LIST) ⇒ Object
Deletes all namespaces with data.
-
.clear_ns(namespace) ⇒ Object
Deletes all data from a namespace.
-
.extract(namespace, key = nil) ⇒ Object, Hash
Gets data from memory.
-
.store(namespace, key, value) ⇒ Object
Saves data into memory.
Class Attribute Details
.data ⇒ Object (readonly)
Returns the value of attribute data.
11 12 13 |
# File 'lib/howitzer/cache.rb', line 11 def data @data end |
Class Method Details
.clear_all_ns(exception_list = SPECIAL_NS_LIST) ⇒ Object
Deletes all namespaces with data
50 51 52 |
# File 'lib/howitzer/cache.rb', line 50 def clear_all_ns(exception_list = SPECIAL_NS_LIST) (@data.keys - exception_list).each { |ns| clear_ns(ns) } end |
.clear_ns(namespace) ⇒ Object
Deletes all data from a namespace
42 43 44 |
# File 'lib/howitzer/cache.rb', line 42 def clear_ns(namespace) init_ns(namespace) end |
.extract(namespace, key = nil) ⇒ Object, Hash
Gets data from memory. Can get all namespace or single data value in namespace using key
33 34 35 36 |
# File 'lib/howitzer/cache.rb', line 33 def extract(namespace, key = nil) check_ns(namespace) key ? @data[namespace][key] : @data[namespace] end |
.store(namespace, key, value) ⇒ Object
Saves data into memory. Marking by a namespace and a key
20 21 22 23 |
# File 'lib/howitzer/cache.rb', line 20 def store(namespace, key, value) check_ns(namespace) @data[namespace][key] = value end |