Module io.netty5.resolver.dns
Package io.netty5.resolver.dns
Class DefaultAuthoritativeDnsServerCache
- java.lang.Object
-
- io.netty5.resolver.dns.DefaultAuthoritativeDnsServerCache
-
- All Implemented Interfaces:
AuthoritativeDnsServerCache
public class DefaultAuthoritativeDnsServerCache extends Object implements AuthoritativeDnsServerCache
Default implementation ofAuthoritativeDnsServerCache
, backed by aConcurrentMap
.
-
-
Constructor Summary
Constructors Constructor Description DefaultAuthoritativeDnsServerCache()
Create a cache that respects the TTL returned by the DNS server.DefaultAuthoritativeDnsServerCache(int minTtl, int maxTtl, Comparator<InetSocketAddress> comparator)
Create a cache.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cache(String hostname, InetSocketAddress address, long originalTtl, EventLoop loop)
Caches a nameserver that should be used to resolve the given hostname.void
clear()
Clears all cached nameservers.boolean
clear(String hostname)
Clears the cached nameservers for the specified hostname.DnsServerAddressStream
get(String hostname)
Returns the cached nameservers that should be used to resolve the given hostname.String
toString()
-
-
-
Constructor Detail
-
DefaultAuthoritativeDnsServerCache
public DefaultAuthoritativeDnsServerCache()
Create a cache that respects the TTL returned by the DNS server.
-
DefaultAuthoritativeDnsServerCache
public DefaultAuthoritativeDnsServerCache(int minTtl, int maxTtl, Comparator<InetSocketAddress> comparator)
Create a cache.- Parameters:
minTtl
- the minimum TTLmaxTtl
- the maximum TTLcomparator
- theComparator
to order theInetSocketAddress
for a hostname ornull
if insertion order should be used.
-
-
Method Detail
-
get
public DnsServerAddressStream get(String hostname)
Description copied from interface:AuthoritativeDnsServerCache
Returns the cached nameservers that should be used to resolve the given hostname. The returnedDnsServerAddressStream
may contain unresolvedInetSocketAddress
es that will be resolved when needed while resolving other domain names.- Specified by:
get
in interfaceAuthoritativeDnsServerCache
- Parameters:
hostname
- the hostname- Returns:
- the cached entries or an
null
if none.
-
cache
public void cache(String hostname, InetSocketAddress address, long originalTtl, EventLoop loop)
Description copied from interface:AuthoritativeDnsServerCache
Caches a nameserver that should be used to resolve the given hostname.- Specified by:
cache
in interfaceAuthoritativeDnsServerCache
- Parameters:
hostname
- the hostnameaddress
- the nameserver address (which may be unresolved).originalTtl
- the TTL as returned by the DNS serverloop
- theEventLoop
used to register the TTL timeout
-
clear
public void clear()
Description copied from interface:AuthoritativeDnsServerCache
Clears all cached nameservers.- Specified by:
clear
in interfaceAuthoritativeDnsServerCache
- See Also:
AuthoritativeDnsServerCache.clear(String)
-
clear
public boolean clear(String hostname)
Description copied from interface:AuthoritativeDnsServerCache
Clears the cached nameservers for the specified hostname.- Specified by:
clear
in interfaceAuthoritativeDnsServerCache
- Returns:
true
if and only if there was an entry for the specified host name in the cache and it has been removed by this method
-
-