public class LruCache extends DnsCache
Modifier and Type | Field and Description |
---|---|
protected LinkedHashMap<DnsMessage,DnsMessage> |
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.
|
DEFAULT_CACHE_SIZE
Constructor and Description |
---|
LruCache() |
LruCache(int capacity)
Create a new LRUCache with given capacity.
|
LruCache(int capacity,
long maxTTL)
Create a new LRUCache with given capacity and upper bound ttl.
|
Modifier and Type | Method and 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 sucessful 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 DnsMessage |
getNormalized(DnsMessage q) |
void |
offer(DnsMessage query,
DnsMessage reply,
DnsName knownAuthoritativeZone) |
protected void |
putNormalized(DnsMessage q,
DnsMessage message) |
String |
toString() |
protected long missCount
protected long expireCount
protected long hitCount
protected int capacity
protected long maxTTL
protected LinkedHashMap<DnsMessage,DnsMessage> backend
public LruCache(int capacity, long maxTTL)
capacity
- The internal capacity.maxTTL
- The upper bound for any ttl.public LruCache(int capacity)
capacity
- The capacity of this cache.public LruCache()
protected void putNormalized(DnsMessage q, DnsMessage message)
putNormalized
in class DnsCache
protected DnsMessage getNormalized(DnsMessage q)
getNormalized
in class DnsCache
public void clear()
public long getMissCount()
public long getExpireCount()
public long getHitCount()
public void offer(DnsMessage query, DnsMessage reply, DnsName knownAuthoritativeZone)