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

# Class Cache

source code

    object --+
             |
            Cache

Simple DNS answer cache.

Instance Methods | [hide private]
__init__(self, cleaning_interval=300.0) Initialize a DNS cache. | source code
maybe_clean(self) Clean the cache if it's time to do so. | source code
dns.resolver.Answer object or None |
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__`

Instance Variables | [hide private]
float | cleaning_interval The number of seconds between cleanings.
dict | data A dictionary of cached data
float | next_cleaning The time the cache should next be cleaned (in seconds since the epoch.)

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, cleaning_interval=300.0) (Constructor) | source code
Initialize a DNS cache. Parameters: `cleaning_interval` (float.) - the number of seconds between periodic cleanings. The default is 300.0 Overrides: object.__init__

### get(self, key) | source code
Get the answer associated with key. Returns None if no answer is cached for the key. Parameters: `key` ((dns.name.Name, int, int) tuple whose values are the query name, rdtype, and rdclass.) - the key Returns: dns.resolver.Answer object or None

### put(self, key, value) | source code
Associate key and value in the cache. Parameters: `key` ((dns.name.Name, int, int) tuple whose values are the query name, rdtype, and rdclass.) - the key `value` (dns.resolver.Answer object) - The answer being cached

### flush(self, key=None) | source code
Flush the cache. If key is specified, only that item is flushed. Otherwise the entire cache is flushed. Parameters: `key` ((dns.name.Name, int, int) tuple or None) - the key to flush

Instance Variable Details | [hide private]

### cleaning_interval The number of seconds between cleanings. The default is 300 (5 minutes). Type: float