Class: MWDictionaryAPI::MemoryCache

Inherits:
Object
  • Object
show all
Defined in:
lib/mw_dictionary_api/memory_cache.rb

Class Method Summary collapse

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

.cacheObject



22
23
24
# File 'lib/mw_dictionary_api/memory_cache.rb', line 22

def self.cache
  @cache ||= {}
end

.clearObject

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