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

Class LRUCache

source code

object --+
         |
        LRUCache

Thread-safe, bounded, least-recently-used DNS answer cache.

This cache is better than the simple cache (above) if you're running a web crawler or other process that does a lot of resolutions. The LRUCache has a maximum number of nodes, and when it is full, the least-recently used node is removed to make space for a new one.

Instance Methods [hide private]
 
__init__(self, max_size=100000)
*max_size*, an ``int``, is the maximum number of nodes to cache; it must be greater than 0.
source code
 
set_max_size(self, max_size) 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, max_size=100000)
(Constructor)

source code 

*max_size*, an ``int``, is the maximum number of nodes to cache; it must be greater than 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.

*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.