Cache Keys#
Internal utilities for generating the cache keys that are used to match requests
Create a normalized cache key from either a request object or |
|
Decode a value from bytes, if hasn’t already been. |
|
Encode a value to bytes, if it hasn’t already been |
|
Get only the headers we should match against, given an optional include list and/or exclude list. |
|
Sort items in a dict |
|
Remove any ignored parameters from the request body |
|
Remove any ignored request headers |
|
Remove ignored parameters from request URL, body, and headers |
|
Remove any ignored request parameters from the URL |
|
|
- requests_cache.cache_keys.create_key(request=None, ignored_parameters=None, match_headers=False, **kwargs)[source]#
Create a normalized cache key from either a request object or
Request
arguments
- requests_cache.cache_keys.decode(value, encoding='utf-8')[source]#
Decode a value from bytes, if hasn’t already been. Note:
PreparedRequest.body
is always encoded in utf-8.- Return type
- requests_cache.cache_keys.encode(value, encoding='utf-8')[source]#
Encode a value to bytes, if it hasn’t already been
- Return type
- requests_cache.cache_keys.get_matched_headers(headers, ignored_parameters, match_headers)[source]#
Get only the headers we should match against, given an optional include list and/or exclude list. Also normalizes headers (sorted/lowercased keys).
- requests_cache.cache_keys.remove_ignored_body_params(request, ignored_parameters)[source]#
Remove any ignored parameters from the request body
- Parameters
request (
Union
[PreparedRequest
,CachedRequest
]) –
- Return type
- requests_cache.cache_keys.remove_ignored_headers(headers, ignored_parameters)[source]#
Remove any ignored request headers
- requests_cache.cache_keys.remove_ignored_params(request, ignored_parameters)[source]#
Remove ignored parameters from request URL, body, and headers
- Parameters
request (
Union
[PreparedRequest
,CachedRequest
]) –
- Return type