summaryrefslogtreecommitdiff
path: root/av98.py
diff options
context:
space:
mode:
authorSolderpunk <solderpunk@sdf.org>2020-08-30 23:17:21 +0200
committerSolderpunk <solderpunk@sdf.org>2020-08-30 23:17:21 +0200
commit08c60e202b93b69e04b2932ac94ae55dfb6096d2 (patch)
tree24bd1f42627a398c3b6fb53eca7694de838d3b1b /av98.py
parent0f328141b91ead6a43741030626f6f56ee96cebd (diff)
Turn some magic numbers into constants.
Diffstat (limited to 'av98.py')
-rwxr-xr-xav98.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/av98.py b/av98.py
index c877f95..3176d31 100755
--- a/av98.py
+++ b/av98.py
@@ -54,6 +54,8 @@ except ModuleNotFoundError:
_VERSION = "1.0.2dev"
_MAX_REDIRECTS = 5
+_MAX_CACHE_SIZE = 10
+_MAX_CACHE_AGE_SECS = 180
# Command abbreviations
_ABBREVS = {
@@ -672,7 +674,7 @@ you'll be able to transparently follow links to Gopherspace!""")
return False
now = time.time()
cached = self.cache_timestamps[url]
- if now - cached > 180:
+ if now - cached > _MAX_CACHE_AGE_SECS:
self._debug("Expiring old cached copy of resource.")
self._remove_from_cache(url)
return False
@@ -689,7 +691,7 @@ you'll be able to transparently follow links to Gopherspace!""")
self.cache_timestamps[url] = time.time()
self.cache[url] = (mime, filename)
- if len(self.cache) > 10:
+ if len(self.cache) > _MAX_CACHE_SIZE:
self._trim_cache()
self._validate_cache()
@@ -704,7 +706,7 @@ you'll be able to transparently follow links to Gopherspace!""")
# Drop other entries if they are older than the limit
now = time.time()
for cached, url in lru[1:]:
- if now - cached > 180:
+ if now - cached > _MAX_CACHE_AGE_SECS:
self._debug("Dropping cached copy of {} from full cache.".format(url))
self._remove_from_cache(url)
else: