@UnstableApi public class DefaultDnsCache extends java.lang.Object implements DnsCache
Modifier and Type | Field and Description |
---|---|
private int |
maxTtl |
private int |
minTtl |
private int |
negativeTtl |
private java.util.concurrent.ConcurrentMap<java.lang.String,java.util.List<DnsCacheEntry>> |
resolveCache |
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
void |
cache(java.lang.String hostname,
DnsRecord[] additionals,
java.net.InetAddress address,
long originalTtl,
EventLoop loop)
Cache a resolved address for a given hostname.
|
void |
cache(java.lang.String hostname,
DnsRecord[] additionals,
java.lang.Throwable cause,
EventLoop loop)
Cache the resolution failure for a given hostname.
|
private java.util.List<DnsCacheEntry> |
cachedEntries(java.lang.String hostname) |
private static void |
cancelExpiration(java.util.List<DnsCacheEntry> entries) |
void |
clear()
Clears all the resolved addresses cached by this resolver.
|
boolean |
clear(java.lang.String hostname)
Clears the resolved addresses of the specified host name from the cache of this resolver.
|
private static boolean |
emptyAdditionals(DnsRecord[] additionals) |
java.util.List<DnsCacheEntry> |
get(java.lang.String hostname,
DnsRecord[] additionals)
Return the cached entries for the given hostname.
|
int |
maxTtl()
Returns the maximum TTL of the cached DNS resource records (in seconds).
|
int |
minTtl()
Returns the minimum TTL of the cached DNS resource records (in seconds).
|
int |
negativeTtl()
Returns the TTL of the cache for the failed DNS queries (in seconds).
|
private void |
scheduleCacheExpiration(java.util.List<DnsCacheEntry> entries,
DnsCacheEntry e,
int ttl,
EventLoop loop) |
java.lang.String |
toString() |
private final java.util.concurrent.ConcurrentMap<java.lang.String,java.util.List<DnsCacheEntry>> resolveCache
private final int minTtl
private final int maxTtl
private final int negativeTtl
public DefaultDnsCache()
public DefaultDnsCache(int minTtl, int maxTtl, int negativeTtl)
minTtl
- the minimum TTLmaxTtl
- the maximum TTLnegativeTtl
- the TTL for failed queriespublic int minTtl()
maxTtl()
public int maxTtl()
minTtl()
public int negativeTtl()
0
, which
disables the cache for negative results.public void clear()
DnsCache
clear
in interface DnsCache
DnsCache.clear(String)
public boolean clear(java.lang.String hostname)
DnsCache
private static boolean emptyAdditionals(DnsRecord[] additionals)
public java.util.List<DnsCacheEntry> get(java.lang.String hostname, DnsRecord[] additionals)
DnsCache
private java.util.List<DnsCacheEntry> cachedEntries(java.lang.String hostname)
public void cache(java.lang.String hostname, DnsRecord[] additionals, java.net.InetAddress address, long originalTtl, EventLoop loop)
DnsCache
public void cache(java.lang.String hostname, DnsRecord[] additionals, java.lang.Throwable cause, EventLoop loop)
DnsCache
private static void cancelExpiration(java.util.List<DnsCacheEntry> entries)
private void scheduleCacheExpiration(java.util.List<DnsCacheEntry> entries, DnsCacheEntry e, int ttl, EventLoop loop)
public java.lang.String toString()
toString
in class java.lang.Object