Package org.minidns.cache
Class LruCache
- java.lang.Object
-
- org.minidns.DnsCache
-
- org.minidns.cache.LruCache
-
- Direct Known Subclasses:
ExtendedLruCache
public class LruCache extends DnsCache
LRU based DNSCache backed by a LinkedHashMap.
-
-
Field Summary
Fields Modifier and Type Field Description protected LinkedHashMap<DnsMessage,CachedDnsQueryResult>backendThe backend cache.protected intcapacityThe internal capacity of the backend cache.protected longexpireCountInternal expire count (subset of misses that was caused by expire).protected longhitCountInternal hit count.protected longmaxTTLThe upper bound of the ttl.protected longmissCountInternal miss count.-
Fields inherited from class org.minidns.DnsCache
DEFAULT_CACHE_SIZE
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear all entries in this cache.longgetExpireCount()The number of expires (cache hits that have had a ttl to low to be retrieved).longgetHitCount()The cache hit count (all successful calls to get).longgetMissCount()Get the miss count of this cache which is the number of fruitless get calls since this cache was last resetted.protected CachedDnsQueryResultgetNormalized(DnsMessage q)voidoffer(DnsMessage query, DnsQueryResult result, DnsName knownAuthoritativeZone)protected voidputNormalized(DnsMessage q, DnsQueryResult result)StringtoString()
-
-
-
Field Detail
-
missCount
protected long missCount
Internal miss count.
-
expireCount
protected long expireCount
Internal expire count (subset of misses that was caused by expire).
-
hitCount
protected long hitCount
Internal hit count.
-
capacity
protected int capacity
The internal capacity of the backend cache.
-
maxTTL
protected long maxTTL
The upper bound of the ttl. All longer TTLs will be capped by this ttl.
-
backend
protected LinkedHashMap<DnsMessage,CachedDnsQueryResult> backend
The backend cache.
-
-
Constructor Detail
-
LruCache
public LruCache(int capacity, long maxTTL)
Create a new LRUCache with given capacity and upper bound ttl.- Parameters:
capacity- The internal capacity.maxTTL- The upper bound for any ttl.
-
LruCache
public LruCache(int capacity)
Create a new LRUCache with given capacity.- Parameters:
capacity- The capacity of this cache.
-
LruCache
public LruCache()
-
-
Method Detail
-
putNormalized
protected void putNormalized(DnsMessage q, DnsQueryResult result)
- Specified by:
putNormalizedin classDnsCache
-
getNormalized
protected CachedDnsQueryResult getNormalized(DnsMessage q)
- Specified by:
getNormalizedin classDnsCache
-
clear
public void clear()
Clear all entries in this cache.
-
getMissCount
public long 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
public long getExpireCount()
The number of expires (cache hits that have had a ttl to low to be retrieved).- Returns:
- The expire count.
-
getHitCount
public long getHitCount()
The cache hit count (all successful calls to get).- Returns:
- The hit count.
-
offer
public void offer(DnsMessage query, DnsQueryResult result, DnsName knownAuthoritativeZone)
-
-