summaryrefslogtreecommitdiff
path: root/requests_cache/session.py
diff options
context:
space:
mode:
authorJordan Cook <jordan.cook@pioneer.com>2022-05-03 15:11:54 -0500
committerJordan Cook <jordan.cook@pioneer.com>2022-05-03 19:58:28 -0500
commit375e611e50b7d2780e8d7007455b48453c9ba4b3 (patch)
treed05ca25bfd5a633170812ecd5282b7a0f690cd27 /requests_cache/session.py
parent7f4c20525770d463c5526fa601e8e3b5472cf2e6 (diff)
downloadrequests-cache-375e611e50b7d2780e8d7007455b48453c9ba4b3.tar.gz
Add 'older_than' argument to remove_expired_responses()
Diffstat (limited to 'requests_cache/session.py')
-rw-r--r--requests_cache/session.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/requests_cache/session.py b/requests_cache/session.py
index 58b35ea..7be3f94 100644
--- a/requests_cache/session.py
+++ b/requests_cache/session.py
@@ -298,13 +298,17 @@ class CacheMixin(MIXIN_BASE):
super().close()
self.cache.close()
- def remove_expired_responses(self, expire_after: ExpirationTime = None):
+ def remove_expired_responses(
+ self, expire_after: ExpirationTime = None, older_than: ExpirationTime = None
+ ):
"""Remove expired and invalid responses from the cache, and optionally reset expiration
Args:
- expire_after: A new expiration time to set on existing cache items
+ expire_after: A new expiration value to set on existing cache items (relative to the
+ current time)
+ older_than: Remove all cache items older than this value
"""
- self.cache.remove_expired_responses(expire_after)
+ self.cache.remove_expired_responses(expire_after, older_than)
def __repr__(self):
return f'<CachedSession(cache={repr(self.cache)}, settings={self.settings})>'