dns :: resolver :: Cache :: Class Cache
[hide private]
[frames] | no frames]

Class Cache

source code

object --+
         |
        Cache

Simple thread-safe DNS answer cache.

Instance Methods [hide private]
 
__init__(self, cleaning_interval=300.0)
*cleaning_interval*, a ``float`` is the number of seconds between periodic cleanings.
source code
 
_maybe_clean(self)
Clean the cache if it's time to do so.
source code
 
get(self, key)
Get the answer associated with *key*.
source code
 
put(self, key, value)
Associate key and value in the cache.
source code
 
flush(self, key=None)
Flush the cache.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, cleaning_interval=300.0)
(Constructor)

source code 

*cleaning_interval*, a ``float`` is the number of seconds between periodic cleanings.

Overrides: object.__init__

get(self, key)

source code 

Get the answer associated with *key*.

Returns None if no answer is cached for the key.

*key*, a ``(dns.name.Name, int, int)`` tuple whose values are the query name, rdtype, and rdclass respectively.

Returns a ``dns.resolver.Answer`` or ``None``.

put(self, key, value)

source code 

Associate key and value in the cache.

*key*, a ``(dns.name.Name, int, int)`` tuple whose values are the query name, rdtype, and rdclass respectively.

*value*, a ``dns.resolver.Answer``, the answer.

flush(self, key=None)

source code 

Flush the cache.

If *key* is not ``None``, only that item is flushed. Otherwise the entire cache is flushed.

*key*, a ``(dns.name.Name, int, int)`` tuple whose values are the query name, rdtype, and rdclass respectively.