| java.lang.Object org.xbill.DNS.Cache
Cache | public class Cache (Code) | | 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 See Also: Credibility author: Brian Wellington |
Constructor Summary | |
public | Cache(int dclass) | public | Cache() Creates an empty Cache for class IN. | public | Cache(String file) Creates a Cache which initially contains all records in the specified file. |
Method Summary | |
public SetResponse | addMessage(Message in) Adds all data from a Message into the Cache. | public synchronized void | addNegative(Name name, int type, SOARecord soa, int cred) Adds a negative entry to the Cache. | public synchronized void | addRRset(RRset rrset, int cred) Adds an RRset to the Cache. | public synchronized void | addRecord(Record r, int cred, Object o) Adds a record to the Cache. | public synchronized void | clearCache() Empties the Cache. | public RRset[] | findAnyRecords(Name name, int type) Looks up Records in the Cache (a wrapper around lookupRecords). | public RRset[] | findRecords(Name name, int type) Looks up credible Records in the Cache (a wrapper around lookupRecords). | public void | flushName(Name name) | public void | flushSet(Name name, int type) | public int | getDClass() Returns the DNS class of this cache. | public int | getMaxCache() Gets the maximum length of time that records will be stored
in this Cache. | public int | getMaxEntries() Gets the maximum number of entries in the Cache, where an entry consists
of all records with a specific Name. | public int | getMaxNCache() Gets the maximum length of time that a negative response will be stored
in this Cache. | public int | getSize() Gets the current number of entries in the Cache, where an entry consists
of all records with a specific Name. | protected synchronized SetResponse | lookup(Name name, int type, int minCred) Finds all matching sets or something that causes the lookup to stop. | public SetResponse | lookupRecords(Name name, int type, int minCred) Looks up Records in the Cache. | public void | setMaxCache(int seconds) Sets the maximum length of time that records will be stored in this
Cache. | public void | setMaxEntries(int entries) Sets the maximum number of entries in the Cache, where an entry consists
of all records with a specific Name. | public void | setMaxNCache(int seconds) Sets the maximum length of time that a negative response will be stored
in this Cache. | public String | toString() Returns the contents of the Cache as a string. |
Cache | public Cache(int dclass)(Code) | | Creates an empty Cache
Parameters: dclass - The DNS class of this cache See Also: DClass |
Cache | public Cache()(Code) | | Creates an empty Cache for class IN.
See Also: DClass |
Cache | public Cache(String file) throws IOException(Code) | | Creates a Cache which initially contains all records in the specified file.
|
addMessage | public SetResponse addMessage(Message in)(Code) | | 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 A SetResponse that reflects what would be returned from a cachelookup, or null if nothing useful could be cached from the message. See Also: Message |
addNegative | public synchronized void addNegative(Name name, int type, SOARecord soa, int cred)(Code) | | Adds a negative entry to the Cache.
Parameters: name - The name of the negative entry Parameters: type - The type of the negative entry Parameters: soa - The SOA record to add to the negative cache entry, or null.The negative cache ttl is derived from the SOA. Parameters: cred - The credibility of the negative entry |
addRRset | public synchronized void addRRset(RRset rrset, int cred)(Code) | | Adds an RRset to the Cache.
Parameters: rrset - The RRset to be added Parameters: cred - The credibility of these records See Also: RRset |
addRecord | public synchronized void addRecord(Record r, int cred, Object o)(Code) | | Adds a record to the Cache.
Parameters: r - The record to be added Parameters: cred - The credibility of the record Parameters: o - The source of the record (this could be a Message, for example) See Also: Record |
clearCache | public synchronized void clearCache()(Code) | | Empties the Cache.
|
findAnyRecords | public RRset[] findAnyRecords(Name name, int type)(Code) | | 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 Parameters: type - The type to look up An array of RRsets, or null See Also: Credibility |
findRecords | public RRset[] findRecords(Name name, int type)(Code) | | 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 Parameters: type - The type to look up An array of RRsets, or null See Also: Credibility |
flushName | public void flushName(Name name)(Code) | | Flushes all RRsets with a given name from the cache
Parameters: name - The name of the records to be flushed See Also: RRset |
flushSet | public void flushSet(Name name, int type)(Code) | | Flushes an RRset from the cache
Parameters: name - The name of the records to be flushed Parameters: type - The type of the records to be flushed See Also: RRset |
getDClass | public int getDClass()(Code) | | Returns the DNS class of this cache.
|
getMaxCache | public int getMaxCache()(Code) | | Gets the maximum length of time that records will be stored
in this Cache. A negative value indicates no limit.
|
getMaxEntries | public int getMaxEntries()(Code) | | Gets the maximum number of entries in the Cache, where an entry consists
of all records with a specific Name. A negative value is treated as an
infinite limit.
|
getMaxNCache | public int getMaxNCache()(Code) | | Gets the maximum length of time that a negative response will be stored
in this Cache. A negative value indicates no limit.
|
getSize | public int getSize()(Code) | | Gets the current number of entries in the Cache, where an entry consists
of all records with a specific Name.
|
lookup | protected synchronized SetResponse lookup(Name name, int type, int minCred)(Code) | | Finds all matching sets or something that causes the lookup to stop.
|
lookupRecords | public SetResponse lookupRecords(Name name, int type, int minCred)(Code) | | Looks up Records in the Cache. This follows CNAMEs and handles negatively
cached data.
Parameters: name - The name to look up Parameters: type - The type to look up Parameters: minCred - The minimum acceptable credibility A SetResponse object See Also: SetResponse See Also: Credibility |
setMaxCache | public void setMaxCache(int seconds)(Code) | | Sets the maximum length of time that records will be stored in this
Cache. A negative value disables this feature (that is, sets no limit).
|
setMaxEntries | public void setMaxEntries(int entries)(Code) | | Sets the maximum number of entries in the Cache, where an entry consists
of all records with a specific Name. A negative value is treated as an
infinite limit.
Note that setting this to a value lower than the current number
of entries will not cause the Cache to shrink immediately.
The default maximum number of entries is 50000.
Parameters: entries - The maximum number of entries in the Cache. |
setMaxNCache | public void setMaxNCache(int seconds)(Code) | | 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).
|
toString | public String toString()(Code) | | Returns the contents of the Cache as a string.
|
|
|