Class: Kaching::StorageProviders::Memory
- Inherits:
-
Object
- Object
- Kaching::StorageProviders::Memory
- Defined in:
- lib/kaching/storage_providers/memory.rb
Class Method Summary collapse
- .data ⇒ Object
- .decr(key) ⇒ Object
- .del(key) ⇒ Object
- .fetch(key, &block) ⇒ Object
- .get(key) ⇒ Object
- .incr(key) ⇒ Object
- .set(key, value) ⇒ Object
Class Method Details
.data ⇒ Object
5 6 7 |
# File 'lib/kaching/storage_providers/memory.rb', line 5 def data @data ||= {} end |
.decr(key) ⇒ Object
34 35 36 37 38 |
# File 'lib/kaching/storage_providers/memory.rb', line 34 def decr(key) data[key] ||= 0 Kaching.logger.info "CACHE dec #{key} = #{data[key] - 1}" data[key] -= 1 end |
.del(key) ⇒ Object
19 20 21 |
# File 'lib/kaching/storage_providers/memory.rb', line 19 def del(key) data.delete(key) end |
.fetch(key, &block) ⇒ Object
23 24 25 26 |
# File 'lib/kaching/storage_providers/memory.rb', line 23 def fetch(key, &block) Kaching.logger.info "CACHE fetch #{key} = #{data[key].inspect}" get(key) || set(key, block.call) end |
.get(key) ⇒ Object
9 10 11 12 |
# File 'lib/kaching/storage_providers/memory.rb', line 9 def get(key) Kaching.logger.info "CACHE read #{key} = #{data[key]}" data[key] end |