Module: Moneta::Monetas::Implementation
- Included in:
- Moneta::Monetas
- Defined in:
- lib/moneta/monetas.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #clear(*args) ⇒ Object
- #delete(key) ⇒ Object
- #fetch(key, value = nil) ⇒ Object
- #has_key?(key) ⇒ Boolean
- #key?(key) ⇒ Boolean
- #store(*args) ⇒ Object
Instance Method Details
#[](key) ⇒ Object
18 19 20 |
# File 'lib/moneta/monetas.rb', line 18 def [](key) read_cache[key] end |
#[]=(key, value) ⇒ Object
27 28 29 30 31 |
# File 'lib/moneta/monetas.rb', line 27 def []=(key, value) @caches.map do |cache| cache[key] = value end.first end |
#clear(*args) ⇒ Object
45 46 47 48 49 |
# File 'lib/moneta/monetas.rb', line 45 def clear(*args) @caches.map do |cache| cache.clear(*args) end.first end |
#delete(key) ⇒ Object
33 34 35 36 37 |
# File 'lib/moneta/monetas.rb', line 33 def delete(key) @caches.map do |cache| cache.delete(key) end.first end |
#fetch(key, value = nil) ⇒ Object
22 23 24 25 |
# File 'lib/moneta/monetas.rb', line 22 def fetch(key, value = nil) value ||= block_given? ? yield(key) : default # TODO: Shouldn't yield if key is present? read_cache[key] || value end |
#has_key?(key) ⇒ Boolean
14 15 16 |
# File 'lib/moneta/monetas.rb', line 14 def has_key?(key) key?(key) end |
#key?(key) ⇒ Boolean
10 11 12 |
# File 'lib/moneta/monetas.rb', line 10 def key?(key) read_cache.key?(key) end |
#store(*args) ⇒ Object
39 40 41 42 43 |
# File 'lib/moneta/monetas.rb', line 39 def store(*args) @caches.map do |cache| cache.store(*args) end.first end |