QMdnsEngine
0.1.0
Multicast DNS library for Qt applications
|
Cache for DNS records More...
#include <qmdnsengine/cache.h>
Signals | |
void | recordExpired (const Record &record) |
Indicate that the specified record expired. More... | |
void | shouldQuery (const Record &record) |
Indicate that a record will expire soon and a new query should be issued. More... | |
Public Member Functions | |
Cache (QObject *parent=0) | |
Create an empty cache. | |
void | addRecord (const Record &record) |
Add a record to the cache. More... | |
bool | lookupRecord (const QByteArray &name, quint16 type, Record &record) const |
Retrieve a single record from the cache. More... | |
bool | lookupRecords (const QByteArray &name, quint16 type, QList< Record > &records) const |
Retrieve multiple records from the cache. More... | |
Records are added to the cache using the addRecord() method which are then stored in the cache until they are considered to have expired, at which point they are purged. The shouldQuery() signal is used to indicate when a record is approaching expiry and the recordExpired() signal indicates when a record has expired (at which point it is removed).
The cache can be queried to retrieve one or more records matching a given type. For example, to retrieve all TXT records that match a given name:
Alternatively, lookupRecord() can be used to find a single record.
void QMdnsEngine::Cache::addRecord | ( | const Record & | record | ) |
record | add this record to the cache |
The TTL for the record will be added to the current time to calculate when the record expires. Existing records of the same name and type will be replaced, resetting their expiration.
bool QMdnsEngine::Cache::lookupRecord | ( | const QByteArray & | name, |
quint16 | type, | ||
Record & | record | ||
) | const |
name | name of record to retrieve or null for any |
type | type of record to retrieve or ANY for all types |
record | storage for the record retrieved |
Some record types allow multiple records to be stored with identical names and types. This method will only retrieve the first matching record. Use lookupRecords() to obtain all of the records.
bool QMdnsEngine::Cache::lookupRecords | ( | const QByteArray & | name, |
quint16 | type, | ||
QList< Record > & | records | ||
) | const |
name | name of records to retrieve or null for any |
type | type of records to retrieve or ANY for all types |
records | storage for the records retrieved |
|
signal |
record | reference to the record that has expired |
|
signal |
record | reference to the record that will soon expire |
This signal is emitted when a record reaches approximately 50%, 85%, 90%, and 95% of its lifetime.