From 9369f00515a05dd8e96b3bba17bafa7c17c49d84 Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Sun, 19 Jul 2020 07:26:13 -0700 Subject: [PATCH] rename statistics class; add documentation --- dns/resolver.py | 6 +++--- doc/resolver-caching.rst | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/dns/resolver.py b/dns/resolver.py index 4d2b72b0..ec163761 100644 --- a/dns/resolver.py +++ b/dns/resolver.py @@ -283,7 +283,7 @@ class Answer: del self.rrset[i] -class CacheStats: +class CacheStatistics: """Cache Statistics """ @@ -296,13 +296,13 @@ class CacheStats: self.misses = 0 def clone(self): - return CacheStats(self.hits, self.misses) + return CacheStatistics(self.hits, self.misses) class CacheBase: def __init__(self): self.lock = _threading.Lock() - self.statistics = CacheStats() + self.statistics = CacheStatistics() def reset_statistics(self): """Reset all statistics to zero.""" diff --git a/doc/resolver-caching.rst b/doc/resolver-caching.rst index f39b8ad9..c2150e81 100644 --- a/doc/resolver-caching.rst +++ b/doc/resolver-caching.rst @@ -11,7 +11,12 @@ the data, and will not return expired entries. Two thread-safe cache implementations are provided, a simple dictionary-based Cache, and an LRUCache which provides cache size -control suitable for use in web crawlers. +control suitable for use in web crawlers. Both are subclasses of +a common base class which provides basic statistics. The LRUCache can +also provide a hits count per cache entry. + +.. autoclass:: dns.resolver.CacheBase + :members: .. autoclass:: dns.resolver.Cache :members: @@ -19,3 +24,5 @@ control suitable for use in web crawlers. .. autoclass:: dns.resolver.LRUCache :members: +.. autoclass:: dns.resolver.CacheStatistics + :members: -- 2.47.3