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

Class Cache

object --+
         |
        Cache


Simple DNS answer cache.
Method Summary
  __init__(self, cleaning_interval)
Initialize a DNS cache.
a new object with type S, a subtype of T __new__(S, ...)
  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.

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

__new__(S, ...)

Returns:
a new object with type S, a subtype of T

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 1.1 on Sat Aug 2 15:09:38 2003 http://epydoc.sf.net