Skip to content

Commit c17ba97

Browse files
committed
Merge pull request #743 from requests-cache/fix-log-msg
Fix log message and DeprecationWarning (0.9)
2 parents 5a48fbf + 5c63c32 commit c17ba97

File tree

7 files changed

+283
-407
lines changed

7 files changed

+283
-407
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Build
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [main, v0.9]
66
tags: ['v*']
77
pull_request:
8-
branches: [main]
8+
branches: [main, v0.9]
99
workflow_dispatch:
1010
env:
1111
LATEST_PY_VERSION: '3.11'

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ repos:
2020
rev: 5.10.1
2121
hooks:
2222
- id: isort
23-
- repo: https://gitlab.com/pycqa/flake8
23+
- repo: https://github.com/pycqa/flake8
2424
rev: 3.9.2
2525
hooks:
2626
- id: flake8

HISTORY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# History
22

3+
## 0.9.8 (Unreleased)
4+
* Fix `DeprecationWarning` raised by `BaseCache.urls`
5+
* Reword ambiguous log message for `BaseCache.delete`
6+
* For custom serializers, handle using a cattrs converter that doesn't support `omit_if_default`
7+
38
## 0.9.7 (2022-10-26)
49
Backport compatibility fixes from 1.0:
510
* **PyInstaller:** Fix potential `AttributeError` due to undetected imports when requests-cache is bundled in a PyInstaller package

docs/reference.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,12 @@ from requests_cache import CachedSession, RedisCache, json_serializer
1212
:::
1313

1414
```{toctree}
15-
:maxdepth: 1
15+
:maxdepth: 2
1616
session
1717
modules/requests_cache.patcher
18-
```
19-
```{toctree}
20-
:maxdepth: 2
2118
modules/requests_cache.backends
2219
modules/requests_cache.models
20+
modules/requests_cache.policy
2321
modules/requests_cache.serializers
24-
```
25-
```{toctree}
26-
:maxdepth: 1
2722
modules/requests_cache.cache_keys
28-
modules/requests_cache.cache_control
2923
```

docs/user_guide/inspection.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,23 @@ For example, if you wanted to to see all URLs requested with a specific method:
5959
You can also inspect `CachedSession.cache.redirects`, which maps redirect URLs to keys of the
6060
responses they redirect to.
6161

62-
Additional `keys()` and `values()` wrapper methods are available on {py:class}`.BaseCache` to get
63-
combined keys and responses.
62+
63+
### Filtering responses
64+
Use {py:meth}`.BaseCache.filter` to get responses with optional filters. By default, it returns all
65+
responses except any invalid ones that would raise an exception:
6466
```python
65-
>>> print('All responses:')
66-
>>> for response in session.cache.values():
67+
>>> for response in session.cache.filter():
6768
>>> print(response)
68-
69-
>>> print('All cache keys for redirects and responses combined:')
70-
>>> print(list(session.cache.keys()))
7169
```
7270

73-
Both methods also take a `check_expiry` argument to exclude expired responses:
71+
Get unexpired responses:
7472
```python
75-
>>> print('All unexpired responses:')
76-
>>> for response in session.cache.values(check_expiry=True):
73+
>>> for response in session.cache.filter(expired=False):
7774
>>> print(response)
7875
```
7976

80-
Similarly, you can get a count of responses with {py:meth}`.BaseCache.response_count`, and optionally
81-
exclude expired responses:
77+
Get keys for **only** expired responses:
8278
```python
83-
>>> print(f'Total responses: {session.cache.response_count()}')
84-
>>> print(f'Unexpired responses: {session.cache.response_count(check_expiry=True)}')
79+
>>> expired_responses = session.cache.filter(valid=False, expired=True)
80+
>>> keys = [response.cache_key for response in expired_responses]
8581
```

0 commit comments

Comments
 (0)