Class: Slugged::MemoryCache
- Inherits:
-
Object
- Object
- Slugged::MemoryCache
- Defined in:
- lib/slugged/memory_cache.rb
Overview
Implements a simple cache store that uses the current processes memory. This makes is primarily used for testing purposes in the situations where caching is used.
Class Method Summary collapse
- .cache ⇒ Object
- .delete(key) ⇒ Object
- .read(key) ⇒ Object
- .reset! ⇒ Object
- .write(key, value, options = {}) ⇒ Object
Class Method Details
.cache ⇒ Object
24 25 26 |
# File 'lib/slugged/memory_cache.rb', line 24 def self.cache @cache ||= {} end |
.delete(key) ⇒ Object
16 17 18 |
# File 'lib/slugged/memory_cache.rb', line 16 def self.delete(key) cache.delete key.to_s end |
.read(key) ⇒ Object
12 13 14 |
# File 'lib/slugged/memory_cache.rb', line 12 def self.read(key) cache[key.to_s] end |
.reset! ⇒ Object
20 21 22 |
# File 'lib/slugged/memory_cache.rb', line 20 def self.reset! @cache = nil end |
.write(key, value, options = {}) ⇒ Object
8 9 10 |
# File 'lib/slugged/memory_cache.rb', line 8 def self.write(key, value, = {}) cache[key.to_s] = value end |