Class: LookupBy::Caching::SafeLRU

Inherits:
LRU
  • Object
show all
Defined in:
lib/lookup_by/caching/safe_lru.rb

Instance Attribute Summary

Attributes inherited from LRU

#lru

Instance Method Summary collapse

Methods inherited from LRU

#to_h

Constructor Details

#initialize(maxsize = nil) ⇒ SafeLRU

Returns a new instance of SafeLRU.



4
5
6
7
# File 'lib/lookup_by/caching/safe_lru.rb', line 4

def initialize(maxsize = nil)
  @mutex = Mutex.new
  super
end

Instance Method Details

#[](key) ⇒ Object



13
14
15
# File 'lib/lookup_by/caching/safe_lru.rb', line 13

def [](key)
  @mutex.synchronize { super }
end

#[]=(key, value) ⇒ Object



17
18
19
# File 'lib/lookup_by/caching/safe_lru.rb', line 17

def []=(key, value)
  @mutex.synchronize { super }
end

#clearObject



9
10
11
# File 'lib/lookup_by/caching/safe_lru.rb', line 9

def clear
  @mutex.synchronize { super }
end

#delete(key) ⇒ Object



25
26
27
# File 'lib/lookup_by/caching/safe_lru.rb', line 25

def delete(key)
  @mutex.synchronize { super }
end

#merge!(hash) ⇒ Object



21
22
23
# File 'lib/lookup_by/caching/safe_lru.rb', line 21

def merge!(hash)
  @mutex.synchronize { super }
end