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

Type Cache

object --+
         |
        Cache


Simple DNS answer cache.
Method Summary
  __init__(self, cleaning_interval)
Initialize a DNS cache.
  flush(self, key)
Flush the cache.
dns.resolver.Answer object or None get(self, key)
Get the answer associated with key.
  maybe_clean(self)
Clean the cache if it's time to do so.
  put(self, key, value)
Associate key and value in the cache.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Instance Variable Summary
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.)

Method Details

__init__(self, cleaning_interval=300.0)
(Constructor)

Initialize a DNS cache.
Parameters:
cleaning_interval - the number of seconds between periodic cleanings. The default is 300.0
           (type=float.)
Overrides:
__builtin__.object.__init__

flush(self, key=None)

Flush the cache.

If key is specified, only that item is flushed. Otherwise the entire cache is flushed.
Parameters:
key - the key to flush
           (type=(dns.name.Name, int, int) tuple or None)

get(self, key)

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

maybe_clean(self)

Clean the cache if it's time to do so.

put(self, key, value)

Associate key and value in the cache.
Parameters:
key - the key
           (type=(dns.name.Name, int, int) tuple whose values are the query name, rdtype, and rdclass.)
value - The answer being cached
           (type=dns.resolver.Answer object)

Instance Variable Details

cleaning_interval

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

data

A dictionary of cached data
Type:
dict

next_cleaning

The time the cache should next be cleaned (in seconds since the epoch.)
Type:
float

Generated by Epydoc 2.1 on Fri Jun 2 14:38:21 2006 http://epydoc.sf.net