Package org.minidns.cache
Class LruCache
java.lang.Object
org.minidns.DnsCache
org.minidns.cache.LruCache
- Direct Known Subclasses:
ExtendedLruCache
LRU based DNSCache backed by a LinkedHashMap.
-
Field Summary
Modifier and TypeFieldDescriptionprotected LinkedHashMap
<DnsMessage, CachedDnsQueryResult> The backend cache.protected int
The internal capacity of the backend cache.protected long
Internal expire count (subset of misses that was caused by expire).protected long
Internal hit count.protected long
The upper bound of the ttl.protected long
Internal miss count.Fields inherited from class org.minidns.DnsCache
DEFAULT_CACHE_SIZE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear all entries in this cache.long
The number of expires (cache hits that have had a ttl to low to be retrieved).long
The cache hit count (all successful calls to get).long
Get the miss count of this cache which is the number of fruitless get calls since this cache was last resetted.protected CachedDnsQueryResult
void
offer
(DnsMessage query, DnsQueryResult result, DnsName knownAuthoritativeZone) protected void
putNormalized
(DnsMessage q, DnsQueryResult result) toString()
-
Field Details
-
missCount
Internal miss count. -
expireCount
Internal expire count (subset of misses that was caused by expire). -
hitCount
Internal hit count. -
capacity
The internal capacity of the backend cache. -
maxTTL
The upper bound of the ttl. All longer TTLs will be capped by this ttl. -
backend
The backend cache.
-
-
Constructor Details
-
LruCache
Create a new LRUCache with given capacity and upper bound ttl.- Parameters:
capacity
- The internal capacity.maxTTL
- The upper bound for any ttl.
-
LruCache
Create a new LRUCache with given capacity.- Parameters:
capacity
- The capacity of this cache.
-
LruCache
public LruCache()
-
-
Method Details
-
putNormalized
- Specified by:
putNormalized
in classDnsCache
-
getNormalized
- Specified by:
getNormalized
in classDnsCache
-
clear
Clear all entries in this cache. -
getMissCount
Get the miss count of this cache which is the number of fruitless get calls since this cache was last resetted.- Returns:
- The number of cache misses.
-
getExpireCount
The number of expires (cache hits that have had a ttl to low to be retrieved).- Returns:
- The expire count.
-
getHitCount
The cache hit count (all successful calls to get).- Returns:
- The hit count.
-
toString
-
offer
-