diff options
author | Jordan Cook <jordan.cook.git@proton.me> | 2022-08-14 19:02:18 -0500 |
---|---|---|
committer | Jordan Cook <jordan.cook.git@proton.me> | 2022-08-23 14:36:40 -0500 |
commit | 5691838ac65bf7a3d80a66b4ae3b1fafb40b68a2 (patch) | |
tree | 92d8072427a4ae2918dca836635b566c3f23baf6 /docs | |
parent | 4a9fb218999460636963b7c4b68e858d40fa6c71 (diff) | |
download | requests-cache-5691838ac65bf7a3d80a66b4ae3b1fafb40b68a2.tar.gz |
Add method to recreate cache keys
Diffstat (limited to 'docs')
-rw-r--r-- | docs/user_guide/matching.md | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/docs/user_guide/matching.md b/docs/user_guide/matching.md index c79e636..0cd0fbd 100644 --- a/docs/user_guide/matching.md +++ b/docs/user_guide/matching.md @@ -92,6 +92,20 @@ cached response: >>> assert response_1.cache_key == response_2.cache_key == response_3.cache_key ``` +### Recreating Cache Keys +There are some situations where request matching behavior may change, which causes previously cached +responses to become obsolete: +* You start using a custom cache key, or change other settings that affect request matching +* A new version of requests-cache is released that includes new or changed request matching behavior + (typically, most non-patch releases) + +In these cases, if you want to keep using your existing cache data, you can use the +`recreate_keys` method: +```python +>>> session = CachedSession() +>>> session.cache.recreate_keys() +``` + ### Cache Key Functions If you want to implement your own request matching, you can provide a cache key function which will take a {py:class}`~requests.PreparedRequest` plus optional keyword args for |