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
9 10 11 |
# File 'lib/mw_dictionary_api/memory_cache.rb', line 9 def self.add(term, result) cache[term] = result end |
.cache ⇒ Object
22 23 24 |
# File 'lib/mw_dictionary_api/memory_cache.rb', line 22 def self.cache @cache ||= {} end |
.clear ⇒ Object
following methods are optional
18 19 20 |
# File 'lib/mw_dictionary_api/memory_cache.rb', line 18 def self.clear cache.clear end |
.find(term) ⇒ Object
5 6 7 |
# File 'lib/mw_dictionary_api/memory_cache.rb', line 5 def self.find(term) cache[term] end |
.remove(term) ⇒ Object
13 14 15 |
# File 'lib/mw_dictionary_api/memory_cache.rb', line 13 def self.remove(term) cache.delete(term) end |