Package io.netty.resolver.dns
Class DefaultDnsCache
- java.lang.Object
-
- io.netty.resolver.dns.DefaultDnsCache
-
-
Constructor Summary
Constructors Constructor Description DefaultDnsCache()Create a cache that respects the TTL returned by the DNS server and doesn't cache negative responses.DefaultDnsCache(int minTtl, int maxTtl, int negativeTtl)Create a cache.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DnsCacheEntrycache(java.lang.String hostname, DnsRecord[] additionals, java.lang.Throwable cause, EventLoop loop)Cache the resolution failure for a given hostname.DnsCacheEntrycache(java.lang.String hostname, DnsRecord[] additionals, java.net.InetAddress address, long originalTtl, EventLoop loop)Create a newDnsCacheEntryand cache a resolved address for a given hostname.voidclear()Clears all the resolved addresses cached by this resolver.booleanclear(java.lang.String hostname)Clears the resolved addresses of the specified host name from the cache of this resolver.java.util.List<? extends DnsCacheEntry>get(java.lang.String hostname, DnsRecord[] additionals)Return the cached entries for the given hostname.intmaxTtl()Returns the maximum TTL of the cached DNS resource records (in seconds).intminTtl()Returns the minimum TTL of the cached DNS resource records (in seconds).intnegativeTtl()Returns the TTL of the cache for the failed DNS queries (in seconds).java.lang.StringtoString()
-
-
-
Constructor Detail
-
DefaultDnsCache
public DefaultDnsCache()
Create a cache that respects the TTL returned by the DNS server and doesn't cache negative responses.
-
DefaultDnsCache
public DefaultDnsCache(int minTtl, int maxTtl, int negativeTtl)Create a cache.- Parameters:
minTtl- the minimum TTLmaxTtl- the maximum TTLnegativeTtl- the TTL for failed queries
-
-
Method Detail
-
minTtl
public int minTtl()
Returns the minimum TTL of the cached DNS resource records (in seconds).- See Also:
maxTtl()
-
maxTtl
public int maxTtl()
Returns the maximum TTL of the cached DNS resource records (in seconds).- See Also:
minTtl()
-
negativeTtl
public int negativeTtl()
Returns the TTL of the cache for the failed DNS queries (in seconds). The default value is0, which disables the cache for negative results.
-
clear
public void clear()
Description copied from interface:DnsCacheClears all the resolved addresses cached by this resolver.- Specified by:
clearin interfaceDnsCache- See Also:
DnsCache.clear(String)
-
clear
public boolean clear(java.lang.String hostname)
Description copied from interface:DnsCacheClears the resolved addresses of the specified host name from the cache of this resolver.
-
get
public java.util.List<? extends DnsCacheEntry> get(java.lang.String hostname, DnsRecord[] additionals)
Description copied from interface:DnsCacheReturn the cached entries for the given hostname.
-
cache
public DnsCacheEntry cache(java.lang.String hostname, DnsRecord[] additionals, java.net.InetAddress address, long originalTtl, EventLoop loop)
Description copied from interface:DnsCacheCreate a newDnsCacheEntryand cache a resolved address for a given hostname.- Specified by:
cachein interfaceDnsCache- Parameters:
hostname- the hostnameadditionals- the additional recordsaddress- the resolved addressoriginalTtl- the TTL as returned by the DNS serverloop- theEventLoopused to register the TTL timeout- Returns:
- The
DnsCacheEntrycorresponding to this cache entry.
-
cache
public DnsCacheEntry cache(java.lang.String hostname, DnsRecord[] additionals, java.lang.Throwable cause, EventLoop loop)
Description copied from interface:DnsCacheCache the resolution failure for a given hostname. Be aware this won't be called with timeout / cancel / transport exceptions.- Specified by:
cachein interfaceDnsCache- Parameters:
hostname- the hostnameadditionals- the additional recordscause- the resolution failureloop- theEventLoopused to register the TTL timeout- Returns:
- The
DnsCacheEntrycorresponding to this cache entry, ornullif this cache doesn't support caching failed responses.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-