public class CaffeineDnsCache extends Object implements ExtendedDnsCache
CaffeineCache
.Modifier and Type | Field and Description |
---|---|
protected static int |
DEFAULT_MAX_SIZE |
protected static int |
DEFAULT_NEGATIVE_TTL_SECS |
protected static int |
MAX_SUPPORTED_TTL_SECS |
Constructor and Description |
---|
CaffeineDnsCache()
Create a cache that respects the TTL returned by the DNS server
and doesn't cache negative responses.
|
CaffeineDnsCache(int minTtl,
int maxTtl,
int negativeTtl,
long maxSize)
Create a cache.
|
Modifier and Type | Method and Description |
---|---|
ExtendedDnsCacheEntry |
cache(String hostname,
io.netty.handler.codec.dns.DnsPtrRecord ptrRecord,
io.netty.channel.EventLoop loop)
Positive caching for reverse lookups.
|
io.netty.resolver.dns.DnsCacheEntry |
cache(String hostname,
io.netty.handler.codec.dns.DnsRecord[] additionals,
InetAddress address,
long originalTtl,
io.netty.channel.EventLoop loop)
Positive caching for normal lookups.
|
io.netty.resolver.dns.DnsCacheEntry |
cache(String hostname,
io.netty.handler.codec.dns.DnsRecord[] additionals,
Throwable cause,
io.netty.channel.EventLoop loop)
Negative caching for failures (or empty reverse lookups).
|
void |
clear() |
boolean |
clear(String hostname) |
List<? extends io.netty.resolver.dns.DnsCacheEntry> |
get(String hostname,
io.netty.handler.codec.dns.DnsRecord[] additionals) |
long |
getSize() |
long |
maxSize()
Returns the maximum number of elements allows in the cache.
|
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).
|
void |
registerMetrics(com.codahale.metrics.MetricRegistry metrics) |
String |
toString() |
void |
unregisterMetrics(com.codahale.metrics.MetricRegistry metrics) |
protected static final int MAX_SUPPORTED_TTL_SECS
protected static final int DEFAULT_NEGATIVE_TTL_SECS
protected static final int DEFAULT_MAX_SIZE
public CaffeineDnsCache()
public CaffeineDnsCache(int minTtl, int maxTtl, int negativeTtl, long maxSize)
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 long maxSize()
public void clear()
clear
in interface io.netty.resolver.dns.DnsCache
public boolean clear(String hostname)
clear
in interface io.netty.resolver.dns.DnsCache
public List<? extends io.netty.resolver.dns.DnsCacheEntry> get(String hostname, io.netty.handler.codec.dns.DnsRecord[] additionals)
get
in interface io.netty.resolver.dns.DnsCache
public io.netty.resolver.dns.DnsCacheEntry cache(String hostname, io.netty.handler.codec.dns.DnsRecord[] additionals, InetAddress address, long originalTtl, io.netty.channel.EventLoop loop)
cache
in interface io.netty.resolver.dns.DnsCache
public ExtendedDnsCacheEntry cache(String hostname, io.netty.handler.codec.dns.DnsPtrRecord ptrRecord, io.netty.channel.EventLoop loop)
cache
in interface ExtendedDnsCache
public io.netty.resolver.dns.DnsCacheEntry cache(String hostname, io.netty.handler.codec.dns.DnsRecord[] additionals, Throwable cause, io.netty.channel.EventLoop loop)
cache
in interface io.netty.resolver.dns.DnsCache
public long getSize()
public void registerMetrics(com.codahale.metrics.MetricRegistry metrics)
public void unregisterMetrics(com.codahale.metrics.MetricRegistry metrics)
Copyright © 2021. All rights reserved.