DefaultDnsCache Class — netty Architecture
Architecture documentation for the DefaultDnsCache class in DefaultDnsCache.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 6b67d8b7_9ce6_8cd4_2a76_4d57f4fe2c7f["DefaultDnsCache"] ec7ccb1d_9656_967e_1bb5_7061ec67e67d["DefaultDnsCache.java"] 6b67d8b7_9ce6_8cd4_2a76_4d57f4fe2c7f -->|defined in| ec7ccb1d_9656_967e_1bb5_7061ec67e67d 2b850ddf_01c8_eb8e_05ab_4a40b28e1902["DefaultDnsCache()"] 6b67d8b7_9ce6_8cd4_2a76_4d57f4fe2c7f -->|method| 2b850ddf_01c8_eb8e_05ab_4a40b28e1902 3df44f45_22fe_c4f2_8f8c_8e06e2515f44["minTtl()"] 6b67d8b7_9ce6_8cd4_2a76_4d57f4fe2c7f -->|method| 3df44f45_22fe_c4f2_8f8c_8e06e2515f44 f8062e1b_6856_44dd_6b9b_edbc912ff538["maxTtl()"] 6b67d8b7_9ce6_8cd4_2a76_4d57f4fe2c7f -->|method| f8062e1b_6856_44dd_6b9b_edbc912ff538 7cfeed73_374c_1c2f_65d9_c384aa6c10a5["negativeTtl()"] 6b67d8b7_9ce6_8cd4_2a76_4d57f4fe2c7f -->|method| 7cfeed73_374c_1c2f_65d9_c384aa6c10a5 97db2735_3133_5307_a49a_670bb03a8df8["clear()"] 6b67d8b7_9ce6_8cd4_2a76_4d57f4fe2c7f -->|method| 97db2735_3133_5307_a49a_670bb03a8df8 86203404_57a7_0f1b_0d62_894c6625cd1d["emptyAdditionals()"] 6b67d8b7_9ce6_8cd4_2a76_4d57f4fe2c7f -->|method| 86203404_57a7_0f1b_0d62_894c6625cd1d c5550e1d_924c_e7f5_544c_55473d5aa3c7["get()"] 6b67d8b7_9ce6_8cd4_2a76_4d57f4fe2c7f -->|method| c5550e1d_924c_e7f5_544c_55473d5aa3c7 b315e3a4_b98e_b543_8e50_bf9cab976514["DnsCacheEntry()"] 6b67d8b7_9ce6_8cd4_2a76_4d57f4fe2c7f -->|method| b315e3a4_b98e_b543_8e50_bf9cab976514 234277d7_9787_07e0_8ef7_5cc4485ba99c["String()"] 6b67d8b7_9ce6_8cd4_2a76_4d57f4fe2c7f -->|method| 234277d7_9787_07e0_8ef7_5cc4485ba99c 73830653_e40d_ad66_cdf5_7b21a1ebada2["Throwable()"] 6b67d8b7_9ce6_8cd4_2a76_4d57f4fe2c7f -->|method| 73830653_e40d_ad66_cdf5_7b21a1ebada2
Relationship Graph
Source Code
resolver-dns/src/main/java/io/netty/resolver/dns/DefaultDnsCache.java lines 41–329
public class DefaultDnsCache implements DnsCache {
private final Cache<DefaultDnsCacheEntry> resolveCache = new Cache<DefaultDnsCacheEntry>() {
@Override
protected boolean shouldReplaceAll(DefaultDnsCacheEntry entry) {
return entry.cause() != null;
}
@Override
protected boolean equals(DefaultDnsCacheEntry entry, DefaultDnsCacheEntry otherEntry) {
if (entry.address() != null) {
return entry.address().equals(otherEntry.address());
}
if (otherEntry.address() != null) {
return false;
}
return entry.cause().equals(otherEntry.cause());
}
};
private final int minTtl;
private final int maxTtl;
private final int negativeTtl;
/**
* Create a cache that respects the TTL returned by the DNS server
* and doesn't cache negative responses.
*/
public DefaultDnsCache() {
this(0, Cache.MAX_SUPPORTED_TTL_SECS, 0);
}
/**
* Create a cache.
* @param minTtl the minimum TTL
* @param maxTtl the maximum TTL
* @param negativeTtl the TTL for failed queries
*/
public DefaultDnsCache(int minTtl, int maxTtl, int negativeTtl) {
this.minTtl = Math.min(Cache.MAX_SUPPORTED_TTL_SECS, checkPositiveOrZero(minTtl, "minTtl"));
this.maxTtl = Math.min(Cache.MAX_SUPPORTED_TTL_SECS, checkPositiveOrZero(maxTtl, "maxTtl"));
if (minTtl > maxTtl) {
throw new IllegalArgumentException(
"minTtl: " + minTtl + ", maxTtl: " + maxTtl + " (expected: 0 <= minTtl <= maxTtl)");
}
this.negativeTtl = Math.min(Cache.MAX_SUPPORTED_TTL_SECS, checkPositiveOrZero(negativeTtl, "negativeTtl"));
}
/**
* Returns the minimum TTL of the cached DNS resource records (in seconds).
*
* @see #maxTtl()
*/
public int minTtl() {
return minTtl;
}
/**
* Returns the maximum TTL of the cached DNS resource records (in seconds).
*
* @see #minTtl()
*/
public int maxTtl() {
return maxTtl;
}
/**
* Returns the TTL of the cache for the failed DNS queries (in seconds). The default value is {@code 0}, which
* disables the cache for negative results.
*/
public int negativeTtl() {
return negativeTtl;
}
@Override
public void clear() {
resolveCache.clear();
}
@Override
Source
Frequently Asked Questions
What is the DefaultDnsCache class?
DefaultDnsCache is a class in the netty codebase, defined in resolver-dns/src/main/java/io/netty/resolver/dns/DefaultDnsCache.java.
Where is DefaultDnsCache defined?
DefaultDnsCache is defined in resolver-dns/src/main/java/io/netty/resolver/dns/DefaultDnsCache.java at line 41.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free