Class: MWDictionaryAPI::MemoryCache
- Inherits:
-
Object
- Object
- MWDictionaryAPI::MemoryCache
- Defined in:
- lib/mw_dictionary_api/memory_cache.rb
Class Method Summary collapse
- .add(term, result) ⇒ Object
- .cache ⇒ Object
-
.clear ⇒ Object
following methods are optional.
- .find(term) ⇒ Object
- .remove(term) ⇒ Object
Class Method Details
.add(term, result) ⇒ Object
11 12 13 |
# File 'lib/mw_dictionary_api/memory_cache.rb', line 11 def self.add(term, result) cache[term] = result end |
.cache ⇒ Object
24 25 26 |
# File 'lib/mw_dictionary_api/memory_cache.rb', line 24 def self.cache @cache ||= {} end |
.clear ⇒ Object
following methods are optional
20 21 22 |
# File 'lib/mw_dictionary_api/memory_cache.rb', line 20 def self.clear cache.clear end |
.find(term) ⇒ Object
7 8 9 |
# File 'lib/mw_dictionary_api/memory_cache.rb', line 7 def self.find(term) cache[term] end |
.remove(term) ⇒ Object
15 16 17 |
# File 'lib/mw_dictionary_api/memory_cache.rb', line 15 def self.remove(term) cache.delete(term) end |