Cache Class — netty Architecture
Architecture documentation for the Cache class in Cache.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 843d703e_e49f_c265_d13f_8db336d5ec36["Cache"] 0a3b4924_5315_7bb5_31fc_ae6f82962074["Cache.java"] 843d703e_e49f_c265_d13f_8db336d5ec36 -->|defined in| 0a3b4924_5315_7bb5_31fc_ae6f82962074 e3c71cae_ddf3_b42e_3a80_e3a9e5ed8673["clear()"] 843d703e_e49f_c265_d13f_8db336d5ec36 -->|method| e3c71cae_ddf3_b42e_3a80_e3a9e5ed8673 c0b89246_8ba9_ca82_e4a0_93b63e2ddcb9["get()"] 843d703e_e49f_c265_d13f_8db336d5ec36 -->|method| c0b89246_8ba9_ca82_e4a0_93b63e2ddcb9 827c41b3_0841_4a5b_8441_f3c6c5c4672f["cache()"] 843d703e_e49f_c265_d13f_8db336d5ec36 -->|method| 827c41b3_0841_4a5b_8441_f3c6c5c4672f 5895be98_e21c_d80b_17de_2b02e0f75f9c["size()"] 843d703e_e49f_c265_d13f_8db336d5ec36 -->|method| 5895be98_e21c_d80b_17de_2b02e0f75f9c 6a024b6a_506e_e679_4216_7ad493859ffd["shouldReplaceAll()"] 843d703e_e49f_c265_d13f_8db336d5ec36 -->|method| 6a024b6a_506e_e679_4216_7ad493859ffd e6619101_3e0e_73bd_20de_3b399bad275a["sortEntries()"] 843d703e_e49f_c265_d13f_8db336d5ec36 -->|method| e6619101_3e0e_73bd_20de_3b399bad275a 202af483_a3a9_66d1_9043_d090b9c3b8cd["equals()"] 843d703e_e49f_c265_d13f_8db336d5ec36 -->|method| 202af483_a3a9_66d1_9043_d090b9c3b8cd
Relationship Graph
Source Code
resolver-dns/src/main/java/io/netty/resolver/dns/Cache.java lines 41–292
abstract class Cache<E> {
private static final AtomicReferenceFieldUpdater<Cache.Entries, ScheduledFuture> FUTURE_UPDATER =
AtomicReferenceFieldUpdater.newUpdater(Cache.Entries.class, ScheduledFuture.class, "expirationFuture");
private static final ScheduledFuture<?> CANCELLED = new ScheduledFuture<Object>() {
@Override
public boolean cancel(boolean mayInterruptIfRunning) {
return false;
}
@Override
public long getDelay(TimeUnit unit) {
// We ignore unit and always return the minimum value to ensure the TTL of the cancelled marker is
// the smallest.
return Long.MIN_VALUE;
}
@Override
public int compareTo(Delayed o) {
throw new UnsupportedOperationException();
}
@Override
public boolean isCancelled() {
return true;
}
@Override
public boolean isDone() {
return true;
}
@Override
public Object get() {
throw new UnsupportedOperationException();
}
@Override
public Object get(long timeout, TimeUnit unit) {
throw new UnsupportedOperationException();
}
};
// Two years are supported by all our EventLoop implementations and so safe to use as maximum.
// See also: https://github.com/netty/netty/commit/b47fb817991b42ec8808c7d26538f3f2464e1fa6
static final int MAX_SUPPORTED_TTL_SECS = (int) TimeUnit.DAYS.toSeconds(365 * 2);
private final ConcurrentMap<String, Entries> resolveCache = new ConcurrentHashMap<>();
/**
* Remove everything from the cache.
*/
final void clear() {
while (!resolveCache.isEmpty()) {
for (Iterator<Entry<String, Entries>> i = resolveCache.entrySet().iterator(); i.hasNext();) {
Map.Entry<String, Entries> e = i.next();
i.remove();
e.getValue().clearAndCancel();
}
}
}
/**
* Clear all entries (if anything exists) for the given hostname and return {@code true} if anything was removed.
*/
final boolean clear(String hostname) {
Entries entries = resolveCache.remove(hostname);
return entries != null && entries.clearAndCancel();
}
/**
* Returns all caches entries for the given hostname.
*/
final List<? extends E> get(String hostname) {
Entries entries = resolveCache.get(hostname);
return entries == null ? null : entries.get();
}
/**
Source
Frequently Asked Questions
What is the Cache class?
Cache is a class in the netty codebase, defined in resolver-dns/src/main/java/io/netty/resolver/dns/Cache.java.
Where is Cache defined?
Cache is defined in resolver-dns/src/main/java/io/netty/resolver/dns/Cache.java at line 41.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free