Class: NerRuby::ModelCache
- Inherits:
-
Object
- Object
- NerRuby::ModelCache
- Defined in:
- lib/ner_ruby/model_cache.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #get(key) ⇒ Object
- #has?(key) ⇒ Boolean
-
#initialize ⇒ ModelCache
constructor
A new instance of ModelCache.
- #set(key, value) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize ⇒ ModelCache
Returns a new instance of ModelCache.
5 6 7 8 |
# File 'lib/ner_ruby/model_cache.rb', line 5 def initialize @cache = {} @mutex = Mutex.new end |
Instance Method Details
#clear ⇒ Object
22 23 24 |
# File 'lib/ner_ruby/model_cache.rb', line 22 def clear @mutex.synchronize { @cache.clear } end |
#get(key) ⇒ Object
10 11 12 |
# File 'lib/ner_ruby/model_cache.rb', line 10 def get(key) @mutex.synchronize { @cache[key] } end |
#has?(key) ⇒ Boolean
18 19 20 |
# File 'lib/ner_ruby/model_cache.rb', line 18 def has?(key) @mutex.synchronize { @cache.key?(key) } end |
#set(key, value) ⇒ Object
14 15 16 |
# File 'lib/ner_ruby/model_cache.rb', line 14 def set(key, value) @mutex.synchronize { @cache[key] = value } end |
#size ⇒ Object
26 27 28 |
# File 'lib/ner_ruby/model_cache.rb', line 26 def size @mutex.synchronize { @cache.size } end |