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>
backend
The backend cache.protected int
capacity
The internal capacity of the backend cache.protected long
expireCount
Internal expire count (subset of misses that was caused by expire).protected long
hitCount
Internal hit count.protected long
maxTTL
The upper bound of the ttl.protected long
missCount
Internal 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 void
clear()
Clear all entries in this cache.long
getExpireCount()
The number of expires (cache hits that have had a ttl to low to be retrieved).long
getHitCount()
The cache hit count (all successful calls to get).long
getMissCount()
Get the miss count of this cache which is the number of fruitless get calls since this cache was last resetted.protected CachedDnsQueryResult
getNormalized(DnsMessage q)
void
offer(DnsMessage query, DnsQueryResult result, DnsName knownAuthoritativeZone)
protected void
putNormalized(DnsMessage q, DnsQueryResult result)
String
toString()
-
-
-
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:
putNormalized
in classDnsCache
-
getNormalized
protected CachedDnsQueryResult getNormalized(DnsMessage q)
- Specified by:
getNormalized
in 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)
-
-