org.xbill.DNS
Class Cache

java.lang.Object
  |
  +--org.xbill.DNS.NameSet
        |
        +--org.xbill.DNS.Cache

public class Cache
extends org.xbill.DNS.NameSet

A cache of DNS records. The cache obeys TTLs, so items are purged after their validity period is complete. Negative answers are cached, to avoid repeated failed DNS queries. The credibility of each RRset is maintained, so that more credible records replace less credible records, and lookups can specify the minimum credibility of data they are requesting.

See Also:
RRset, Credibility

Constructor Summary
Cache()
          Creates an empty Cache
Cache(String file)
          Creates a Cache which initially contains all records in the specified file
 
Method Summary
 void addMessage(Message in)
          Adds all data from a Message into the Cache.
 void addNegative(Name name, short type, short dclass, int ttl, byte cred, Object o)
          Adds a negative entry to the Cache
 void addRecord(Record r, byte cred, Object o)
          Adds a record to the Cache
 void addRRset(RRset rrset, byte cred, Object o)
          Adds an RRset to the Cache
 void clearCache()
          Empties the Cache
 RRset[] findAnyRecords(Name name, short type, short dclass)
          Looks up Records in the Cache (a wrapper around lookupRecords).
 RRset[] findRecords(Name name, short type, short dclass)
          Looks up credible Records in the Cache (a wrapper around lookupRecords).
 SetResponse lookupRecords(Name name, short type, short dclass, byte minCred)
          Looks up Records in the Cache.
 void setCleanInterval(int minutes)
          Sets the interval (in minutes) that all expired records will be expunged the cache.
 void setMaxNCache(int seconds)
          Sets the maximum length of time that a negative response will be stored in this Cache.
 void setSecurePolicy()
          Mandates that all data stored in this Cache must be verified and proven to be secure, using a verifier (as defined in setVerifier).
 void setVerifier(Verifier v)
          Defines a module to be used for data verification (DNSSEC).
 
Methods inherited from class org.xbill.DNS.NameSet
addSet, clear, findExactSet, findName, findSets, removeName, removeSet, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Cache

public Cache()
Creates an empty Cache

Cache

public Cache(String file)
      throws IOException
Creates a Cache which initially contains all records in the specified file
Method Detail

clearCache

public void clearCache()
Empties the Cache

addRecord

public void addRecord(Record r,
                      byte cred,
                      Object o)
Adds a record to the Cache
Parameters:
r - The record to be added
cred - The credibility of the record
o - The source of the record (this could be a Message, for example)

addRRset

public void addRRset(RRset rrset,
                     byte cred,
                     Object o)
Adds an RRset to the Cache
Parameters:
r - The RRset to be added
cred - The credibility of these records
o - The source of this RRset (this could be a Message, for example)
See Also:
RRset

addNegative

public void addNegative(Name name,
                        short type,
                        short dclass,
                        int ttl,
                        byte cred,
                        Object o)
Adds a negative entry to the Cache
Parameters:
name - The name of the negative entry
type - The type of the negative entry
dclass - The class of the negative entry
ttl - The ttl of the negative entry
cred - The credibility of the negative entry
o - The source of this data

lookupRecords

public SetResponse lookupRecords(Name name,
                                 short type,
                                 short dclass,
                                 byte minCred)
Looks up Records in the Cache. This follows CNAMEs and handles negatively cached data.
Parameters:
name - The name to look up
type - The type to look up
dclass - The class to look up
minCred - The minimum acceptable credibility
Returns:
A SetResponse object
See Also:
SetResponse, Credibility

findRecords

public RRset[] findRecords(Name name,
                           short type,
                           short dclass)
Looks up credible Records in the Cache (a wrapper around lookupRecords). Unlike lookupRecords, this given no indication of why failure occurred.
Parameters:
name - The name to look up
type - The type to look up
dclass - The class to look up
Returns:
An array of RRsets, or null
See Also:
Credibility

findAnyRecords

public RRset[] findAnyRecords(Name name,
                              short type,
                              short dclass)
Looks up Records in the Cache (a wrapper around lookupRecords). Unlike lookupRecords, this given no indication of why failure occurred.
Parameters:
name - The name to look up
type - The type to look up
dclass - The class to look up
Returns:
An array of RRsets, or null
See Also:
Credibility

addMessage

public void addMessage(Message in)
Adds all data from a Message into the Cache. Each record is added with the appropriate credibility, and negative answers are cached as such.
Parameters:
in - The Message to be added
See Also:
Message

setVerifier

public void setVerifier(Verifier v)
Defines a module to be used for data verification (DNSSEC). An implementation is found in org.xbill.DNSSEC.security.DNSSECVerifier, which requires Java 2 or above and the Java Cryptography Extensions.

setSecurePolicy

public void setSecurePolicy()
Mandates that all data stored in this Cache must be verified and proven to be secure, using a verifier (as defined in setVerifier).

setMaxNCache

public void setMaxNCache(int seconds)
Sets the maximum length of time that a negative response will be stored in this Cache. A negative value disables this feature (that is, sets no limit).

setCleanInterval

public void setCleanInterval(int minutes)
Sets the interval (in minutes) that all expired records will be expunged the cache. The default is 30 minutes. 0 or a negative value disables this feature.