Patcher#
Utilities for patching requests. See Patching for general usage info.
Warning
These functions are not thread-safe. Use CachedSession if you want to use
caching in a multi-threaded environment.
Clear the currently installed cache (if any)  | 
|
Remove responses from the cache according one or more conditions. See :py:meth:`.BaseCache.delete for usage details.  | 
|
Context manager for temporarily disabling caching for all   | 
|
Context manager for temporarily enabling caching for all   | 
|
Get the internal cache object from the currently installed   | 
|
Install the cache for all   | 
|
Indicate whether or not requests-cache is currently installed  | 
|
Remove expired responses from the cache  | 
|
Disable the cache by restoring the original   | 
- requests_cache.patcher.delete(*args, **kwargs)[source]#
 Remove responses from the cache according one or more conditions. See :py:meth:`.BaseCache.delete for usage details.
- requests_cache.patcher.disabled()[source]#
 Context manager for temporarily disabling caching for all
requestsfunctionsExample
>>> with requests_cache.disabled(): ... requests.get('https://httpbin.org/get')
- requests_cache.patcher.enabled(*args, **kwargs)[source]#
 Context manager for temporarily enabling caching for all
requestsfunctionsExample
>>> with requests_cache.enabled('cache.db'): ... requests.get('https://httpbin.org/get')
Accepts the same arguments as
CachedSessionandinstall_cache().
- requests_cache.patcher.get_cache()[source]#
 Get the internal cache object from the currently installed
CachedSession(if any)
- requests_cache.patcher.install_cache(cache_name='http_cache', backend=None, session_factory=<class 'requests_cache.session.CachedSession'>, **kwargs)[source]#
 Install the cache for all
requestsfunctions by monkey-patchingrequests.SessionExample
>>> requests_cache.install_cache('demo_cache')
Accepts all the same parameters as
CachedSession. Additional parameters:- Parameters:
 session_factory (
Type[Session]) – Session class to use. It must inherit from eitherCachedSessionorCacheMixincache_name (
str) –
- requests_cache.patcher.is_installed()[source]#
 Indicate whether or not requests-cache is currently installed
- Return type:
 
- requests_cache.patcher.uninstall_cache()[source]#
 Disable the cache by restoring the original
requests.Session