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
FieldsModifier and TypeFieldDescriptionprotected LinkedHashMap<DnsMessage, CachedDnsQueryResult> The backend cache.protected intThe internal capacity of the backend cache.protected longInternal expire count (subset of misses that was caused by expire).protected longInternal hit count.protected longThe upper bound of the ttl.protected longInternal miss count.Fields inherited from class org.minidns.DnsCache
DEFAULT_CACHE_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear all entries in this cache.longThe number of expires (cache hits that have had a ttl to low to be retrieved).longThe cache hit count (all successful calls to get).longGet the miss count of this cache which is the number of fruitless get calls since this cache was last resetted.protected CachedDnsQueryResultvoidoffer(DnsMessage query, DnsQueryResult result, DnsName knownAuthoritativeZone) protected voidputNormalized(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:
putNormalizedin classDnsCache
-
getNormalized
- Specified by:
getNormalizedin 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
-