Class: AtomicCache::Storage::InstanceMemory
- Inherits:
-
Memory
- Object
- Store
- Memory
- AtomicCache::Storage::InstanceMemory
show all
- Defined in:
- lib/atomic_cache/storage/instance_memory.rb
Overview
A storage adapter which keeps all values in memory, private to the instance
Instance Method Summary
collapse
Methods inherited from Memory
#add, #delete, #read, #set
Methods inherited from Store
#add, #delete, #read, #set
Constructor Details
Returns a new instance of InstanceMemory.
11
12
13
14
|
# File 'lib/atomic_cache/storage/instance_memory.rb', line 11
def initialize(*args)
reset
super(*args)
end
|
Instance Method Details
#reset ⇒ Object
16
17
18
|
# File 'lib/atomic_cache/storage/instance_memory.rb', line 16
def reset
@store = {}
end
|
#store ⇒ Object
20
21
22
|
# File 'lib/atomic_cache/storage/instance_memory.rb', line 20
def store
@store
end
|
#store_op(key, user_options = {}) {|normalized_key, user_options| ... } ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/atomic_cache/storage/instance_memory.rb', line 24
def store_op(key, user_options={})
if !key.present?
desc = if key.nil? then 'Nil' else 'Empty' end
raise ArgumentError.new("#{desc} key given for storage operation") unless key.present?
end
normalized_key = key.to_sym
yield(normalized_key, user_options)
end
|