-def purge_cache(obj, age=4):
- """purge old entries in http client cache
- """
- now = datetime.utcnow()
- if now.hour == obj.timestamp.hour:
- return
- obj.timestamp = datetime.utcnow()
- cache = obj.cache
- delta = timedelta(hours=age)
- for url in list(cache.keys()):
- timestamp = cache.get(url).created()
- if now - timestamp > delta:
- cache.pop(url)
-