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 Details

    • 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<org.minidns.dnsmessage.DnsMessage,CachedDnsQueryResult> backend
      The backend cache.
  • Constructor Details

    • 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 Details

    • putNormalized

      protected void putNormalized(org.minidns.dnsmessage.DnsMessage q, DnsQueryResult result)
      Specified by:
      putNormalized in class DnsCache
    • getNormalized

      protected CachedDnsQueryResult getNormalized(org.minidns.dnsmessage.DnsMessage q)
      Specified by:
      getNormalized in class DnsCache
    • 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.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • offer

      public void offer(org.minidns.dnsmessage.DnsMessage query, DnsQueryResult result, org.minidns.dnsname.DnsName knownAuthoritativeZone)
      Specified by:
      offer in class DnsCache