summaryrefslogtreecommitdiff
path: root/requests_cache/patcher.py
diff options
context:
space:
mode:
authorJordan Cook <jordan.cook@pioneer.com>2022-06-10 17:36:20 -0500
committerJordan Cook <jordan.cook@pioneer.com>2022-06-11 11:50:24 -0500
commit275f675bc2fd6d5ffa3363a436867258a8eccd26 (patch)
tree7272c4076ad0c0dd7b375d2052b6f7c0b232d968 /requests_cache/patcher.py
parent319a68b6f5a38344fd70c3db346e78f9a78a0d8c (diff)
downloadrequests-cache-275f675bc2fd6d5ffa3363a436867258a8eccd26.tar.gz
Split up remove_expired_reponses() into remove() and reset_expiration() methods, with more granular arguments
Diffstat (limited to 'requests_cache/patcher.py')
-rw-r--r--requests_cache/patcher.py11
1 files changed, 3 insertions, 8 deletions
diff --git a/requests_cache/patcher.py b/requests_cache/patcher.py
index fd47005..b11cbec 100644
--- a/requests_cache/patcher.py
+++ b/requests_cache/patcher.py
@@ -14,7 +14,6 @@ from typing import Optional, Type
import requests
from .backends import BackendSpecifier, BaseCache, init_backend
-from .policy import ExpirationTime
from .session import CachedSession, OriginalSession
logger = getLogger(__name__)
@@ -107,15 +106,11 @@ def clear():
get_cache().clear()
-def remove_expired_responses(expire_after: ExpirationTime = None):
- """Remove expired responses from the cache, and optionally reset expiration
-
- Args:
- expire_after: A new expiration time to set on existing cache items
- """
+def remove_expired_responses():
+ """Remove expired and invalid responses from the cache"""
session = requests.Session()
if isinstance(session, CachedSession):
- session.remove_expired_responses(expire_after)
+ session.cache.remove(expired=True)
def _patch_session_factory(session_factory: Type[OriginalSession] = CachedSession):