Class: HTTPX::Resolver::Cache::Memory
- Inherits:
-
Base
- Object
- Base
- HTTPX::Resolver::Cache::Memory
show all
- Defined in:
- lib/httpx/resolver/cache/memory.rb
Overview
Implementation of a thread-safe in-memory LRU resolver cache.
Constant Summary
Constants inherited
from Base
Base::CACHE_MUTEX, Base::HOSTS, Base::MAX_CACHE_SIZE
Instance Method Summary
collapse
Methods inherited from Base
cache, #resolve
Constructor Details
#initialize ⇒ Memory
7
8
9
10
11
12
|
# File 'lib/httpx/resolver/cache/memory.rb', line 7
def initialize
super
@hostnames = []
@lookups = Hash.new { |h, k| h[k] = [] }
@lookup_mutex = Thread::Mutex.new
end
|
Instance Method Details
#evict(hostname, ip) ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/httpx/resolver/cache/memory.rb', line 27
def evict(hostname, ip)
ip = ip.to_s
synchronize do |lookups, hostnames|
_evict(hostname, ip, lookups, hostnames)
end
end
|
#get(hostname) ⇒ Object
14
15
16
17
18
19
|
# File 'lib/httpx/resolver/cache/memory.rb', line 14
def get(hostname)
now = Utils.now
synchronize do |lookups, hostnames|
_get(hostname, lookups, hostnames, now)
end
end
|
#set(hostname, family, entries) ⇒ Object
21
22
23
24
25
|
# File 'lib/httpx/resolver/cache/memory.rb', line 21
def set(hostname, family, entries)
synchronize do |lookups, hostnames|
_set(hostname, family, entries, lookups, hostnames)
end
end
|