Class: Trocla::Stores::Memory
- Inherits:
-
Trocla::Store
- Object
- Trocla::Store
- Trocla::Stores::Memory
- Defined in:
- lib/trocla/stores/memory.rb
Overview
a simple in memory store just as an example
Instance Attribute Summary collapse
-
#memory ⇒ Object
readonly
Returns the value of attribute memory.
Attributes inherited from Trocla::Store
Instance Method Summary collapse
- #get(key, format) ⇒ Object
-
#initialize(config, trocla) ⇒ Memory
constructor
A new instance of Memory.
- #set(key, format, value, options = {}) ⇒ Object
Methods inherited from Trocla::Store
Constructor Details
#initialize(config, trocla) ⇒ Memory
Returns a new instance of Memory.
4 5 6 7 |
# File 'lib/trocla/stores/memory.rb', line 4 def initialize(config,trocla) super(config,trocla) @memory = Hash.new({}) end |
Instance Attribute Details
#memory ⇒ Object (readonly)
Returns the value of attribute memory.
3 4 5 |
# File 'lib/trocla/stores/memory.rb', line 3 def memory @memory end |
Instance Method Details
#get(key, format) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/trocla/stores/memory.rb', line 9 def get(key,format) unless expired?(key) memory[key][format] else delete_all(key) nil end end |
#set(key, format, value, options = {}) ⇒ Object
17 18 19 20 |
# File 'lib/trocla/stores/memory.rb', line 17 def set(key,format,value,={}) super(key,format,value,) set_expires(key,['expires']) end |