psycache 26.3.0__tar.gz → 26.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {psycache-26.3.0 → psycache-26.4.0}/.github/AI_POLICY.md +6 -0
- {psycache-26.3.0 → psycache-26.4.0}/.github/PULL_REQUEST_TEMPLATE.md +1 -1
- psycache-26.4.0/.github/SECURITY.md +22 -0
- {psycache-26.3.0 → psycache-26.4.0}/.github/workflows/ci.yml +22 -25
- {psycache-26.3.0 → psycache-26.4.0}/.github/workflows/codeql-analysis.yml +4 -4
- {psycache-26.3.0 → psycache-26.4.0}/.github/workflows/pypi-package.yml +4 -4
- {psycache-26.3.0 → psycache-26.4.0}/.github/workflows/zizmor.yml +2 -2
- {psycache-26.3.0 → psycache-26.4.0}/.pre-commit-config.yaml +3 -3
- {psycache-26.3.0 → psycache-26.4.0}/.readthedocs.yaml +4 -3
- {psycache-26.3.0 → psycache-26.4.0}/CHANGELOG.md +19 -4
- {psycache-26.3.0 → psycache-26.4.0}/PKG-INFO +35 -16
- {psycache-26.3.0 → psycache-26.4.0}/README.md +12 -4
- {psycache-26.3.0 → psycache-26.4.0}/conftest.py +13 -0
- {psycache-26.3.0 → psycache-26.4.0}/docs/cleanup.md +59 -1
- {psycache-26.3.0 → psycache-26.4.0}/docs/getting-started.md +10 -15
- {psycache-26.3.0 → psycache-26.4.0}/docs/index.md +3 -3
- {psycache-26.3.0 → psycache-26.4.0}/docs/instrumentation/custom.md +3 -1
- {psycache-26.3.0 → psycache-26.4.0}/docs/pool-adapters.md +1 -1
- {psycache-26.3.0 → psycache-26.4.0}/pyproject.toml +58 -18
- {psycache-26.3.0 → psycache-26.4.0}/src/psycache/__main__.py +11 -9
- {psycache-26.3.0 → psycache-26.4.0}/src/psycache/_async.py +2 -6
- {psycache-26.3.0 → psycache-26.4.0}/src/psycache/_sql.py +24 -25
- {psycache-26.3.0 → psycache-26.4.0}/src/psycache/_sync.py +6 -9
- psycache-26.4.0/src/psycache/_tables.py +26 -0
- {psycache-26.3.0 → psycache-26.4.0}/src/psycache/sqlalchemy.py +10 -4
- {psycache-26.3.0 → psycache-26.4.0}/src/psycache/typing.py +6 -3
- {psycache-26.3.0 → psycache-26.4.0}/tests/test_cli.py +29 -9
- {psycache-26.3.0 → psycache-26.4.0}/tests/test_raw.py +9 -9
- {psycache-26.3.0 → psycache-26.4.0}/tests/test_raw_async.py +3 -3
- psycache-26.4.0/tests/test_sqlalchemy.py +40 -0
- psycache-26.4.0/tests/test_sqlalchemy_async.py +44 -0
- {psycache-26.3.0 → psycache-26.4.0}/tox.ini +8 -6
- psycache-26.4.0/typing_tests/__init__.py +0 -0
- {psycache-26.3.0/tests/typing → psycache-26.4.0/typing_tests}/core.py +2 -0
- psycache-26.3.0/src/psycache/_tables.py +0 -26
- psycache-26.3.0/tests/test_sqlalchemy.py +0 -85
- {psycache-26.3.0 → psycache-26.4.0}/.git_archival.txt +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/.gitattributes +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/.github/CODE_OF_CONDUCT.md +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/.github/CONTRIBUTING.md +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/.github/FUNDING.yml +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/.github/dependabot.yml +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/.gitignore +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/.python-version +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/LICENSE +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/docs/api-types.md +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/docs/api.md +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/docs/assets/javascript/readthedocs.js +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/docs/async.md +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/docs/instrumentation/index.md +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/docs/instrumentation/prometheus.md +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/docs/instrumentation/sentry.md +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/docs/quality-of-life.md +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/docs/raw-queries.md +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/src/psycache/__init__.py +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/src/psycache/_durations.py +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/src/psycache/instrumentation/__init__.py +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/src/psycache/instrumentation/_spans.py +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/src/psycache/instrumentation/prometheus.py +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/src/psycache/instrumentation/sentry.py +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/src/psycache/psycopg_pool.py +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/src/psycache/py.typed +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/tests/__init__.py +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/tests/test_maintenance.py +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/tests/test_psycopg_pool.py +0 -0
- {psycache-26.3.0/tests/typing → psycache-26.4.0/typing_tests}/README.md +0 -0
- {psycache-26.3.0/tests/typing → psycache-26.4.0/typing_tests}/psycopg_pool.py +0 -0
- {psycache-26.3.0/tests/typing → psycache-26.4.0/typing_tests}/sqlalchemy.py +0 -0
- {psycache-26.3.0 → psycache-26.4.0}/zensical.toml +0 -0
|
@@ -17,13 +17,19 @@ However, due to both legal and human reasons, we have to establish boundaries.
|
|
|
17
17
|
>
|
|
18
18
|
> - Absolutely **no** unsupervised agentic tools like OpenClaw.
|
|
19
19
|
>
|
|
20
|
+
> - Do **not** trigger bots like Copilot on this repository.
|
|
21
|
+
> GitHub won't let us block Copilot, but it's a great way to tell you didn't read this.
|
|
22
|
+
>
|
|
20
23
|
> ---
|
|
21
24
|
>
|
|
22
25
|
> By submitting a pull request, you certify that:
|
|
23
26
|
>
|
|
24
27
|
> - You are the author of the contribution or have the legal right to submit it.
|
|
28
|
+
>
|
|
25
29
|
> - You either hold the copyright to the changes or have explicit legal authorization to contribute them under this project's license.
|
|
30
|
+
>
|
|
26
31
|
> - You understand the code.
|
|
32
|
+
>
|
|
27
33
|
> - You accept full responsibility for it.
|
|
28
34
|
|
|
29
35
|
|
|
@@ -20,7 +20,7 @@ You may check boxes that don't apply to your pull request to indicate that there
|
|
|
20
20
|
- [ ] This pull request is [**not** from my `main` branch](https://hynek.me/articles/pull-requests-branch/).
|
|
21
21
|
- Consider granting [push permissions to the PR branch](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork), so maintainers can fix minor issues themselves without pestering you.
|
|
22
22
|
- [ ] There's **tests** for all new and changed code.
|
|
23
|
-
- [ ] **New APIs** are added to our typing tests at <https://github.com/hynek/psycache/blob/main/
|
|
23
|
+
- [ ] **New APIs** are added to our typing tests at <https://github.com/hynek/psycache/blob/main/typing_tests/>.
|
|
24
24
|
- [ ] Updated **documentation** for changed code.
|
|
25
25
|
- [ ] New functions/classes have to be added to `docs/core-concepts.md` or one of the integration guides by hand.
|
|
26
26
|
- [ ] Changed/added classes/methods/functions have appropriate `versionadded`, `versionchanged`, or `deprecated` [directives](http://www.sphinx-doc.org/en/stable/markup/para.html#directive-versionadded).
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
We follow [Calendar Versioning](https://calver.org) with generous backwards-compatibility guarantees.
|
|
6
|
+
Therefore, we only support the latest version.
|
|
7
|
+
|
|
8
|
+
That said, you shouldn't be afraid to upgrade if you're only using our documented public APIs and pay attention to `DeprecationWarning`s.
|
|
9
|
+
Whenever there is a need to break compatibility, it is announced in the changelog and raises a `DeprecationWarning` for a year (if possible) before it's finally really broken.
|
|
10
|
+
|
|
11
|
+
> [!WARNING]
|
|
12
|
+
> There is **one** exception:
|
|
13
|
+
>
|
|
14
|
+
> APIs may be marked as *provisional*.
|
|
15
|
+
> They are not guaranteed to be stable and may change or be removed without prior notice.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## Reporting a Vulnerability
|
|
19
|
+
|
|
20
|
+
If you think you found a vulnerability, please use [GitHub's security advisory form](https://github.com/hynek/svcs/security/advisories/new), or email Hynek Schlawack at <hs@ox.cx>.
|
|
21
|
+
|
|
22
|
+
If you submit AI slop, you will be permanently blocked.
|
|
@@ -9,8 +9,6 @@ on:
|
|
|
9
9
|
|
|
10
10
|
env:
|
|
11
11
|
FORCE_COLOR: "1" # Make tools pretty.
|
|
12
|
-
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
|
13
|
-
PIP_NO_PYTHON_VERSION_WARNING: "1"
|
|
14
12
|
|
|
15
13
|
concurrency:
|
|
16
14
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
@@ -24,12 +22,12 @@ jobs:
|
|
|
24
22
|
runs-on: ubuntu-latest
|
|
25
23
|
|
|
26
24
|
steps:
|
|
27
|
-
- uses: actions/checkout@
|
|
25
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
28
26
|
with:
|
|
29
27
|
fetch-depth: 0
|
|
30
28
|
persist-credentials: false
|
|
31
29
|
|
|
32
|
-
- uses: hynek/build-and-inspect-python-package@
|
|
30
|
+
- uses: hynek/build-and-inspect-python-package@2abe76da66d0a6a4a227101f9348ee855797cfa5 # v3.0.1
|
|
33
31
|
id: baipp
|
|
34
32
|
|
|
35
33
|
outputs:
|
|
@@ -60,11 +58,11 @@ jobs:
|
|
|
60
58
|
- run: |
|
|
61
59
|
tar xf dist/*.tar.gz --strip-components=1
|
|
62
60
|
rm -rf src
|
|
63
|
-
- uses: actions/setup-python@
|
|
61
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
64
62
|
with:
|
|
65
63
|
python-version: ${{ matrix.python-version }}
|
|
66
64
|
allow-prereleases: true
|
|
67
|
-
- uses: hynek/setup-cached-uv@
|
|
65
|
+
- uses: hynek/setup-cached-uv@34e35d30f1ebc7421a5cc733bca38dcc62603960 # v2.6.0
|
|
68
66
|
|
|
69
67
|
- name: Start PostgreSQL
|
|
70
68
|
run: |
|
|
@@ -80,7 +78,8 @@ jobs:
|
|
|
80
78
|
|
|
81
79
|
- name: Run tests
|
|
82
80
|
run: >
|
|
83
|
-
uvx --with tox-uv
|
|
81
|
+
uvx --with tox-uv-bare
|
|
82
|
+
tox run
|
|
84
83
|
--installpkg dist/*.whl
|
|
85
84
|
-f ${PYTHON}-tests
|
|
86
85
|
|
|
@@ -99,13 +98,13 @@ jobs:
|
|
|
99
98
|
if: always()
|
|
100
99
|
|
|
101
100
|
steps:
|
|
102
|
-
- uses: actions/checkout@
|
|
101
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
103
102
|
with:
|
|
104
103
|
persist-credentials: false
|
|
105
|
-
- uses: actions/setup-python@
|
|
104
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
106
105
|
with:
|
|
107
106
|
python-version-file: .python-version
|
|
108
|
-
- uses: hynek/setup-cached-uv@
|
|
107
|
+
- uses: hynek/setup-cached-uv@34e35d30f1ebc7421a5cc733bca38dcc62603960 # v2.6.0
|
|
109
108
|
|
|
110
109
|
- name: Download coverage data
|
|
111
110
|
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
|
@@ -145,13 +144,13 @@ jobs:
|
|
|
145
144
|
name: Packages
|
|
146
145
|
path: dist
|
|
147
146
|
- run: tar xf dist/*.tar.gz --strip-components=1
|
|
148
|
-
- uses: actions/setup-python@
|
|
147
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
149
148
|
with:
|
|
150
149
|
python-version-file: .python-version
|
|
151
|
-
- uses: hynek/setup-cached-uv@
|
|
150
|
+
- uses: hynek/setup-cached-uv@34e35d30f1ebc7421a5cc733bca38dcc62603960 # v2.6.0
|
|
152
151
|
|
|
153
152
|
- run: >
|
|
154
|
-
uvx --with tox-uv
|
|
153
|
+
uvx --with tox-uv-bare
|
|
155
154
|
tox run -f typing
|
|
156
155
|
|
|
157
156
|
docs:
|
|
@@ -165,11 +164,10 @@ jobs:
|
|
|
165
164
|
name: Packages
|
|
166
165
|
path: dist
|
|
167
166
|
- run: tar xf dist/*.tar.gz --strip-components=1
|
|
168
|
-
- uses: actions/setup-python@
|
|
167
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
169
168
|
with:
|
|
170
|
-
# Keep in sync with tox.ini's base_python_file.
|
|
171
169
|
python-version-file: .python-version
|
|
172
|
-
- uses: hynek/setup-cached-uv@
|
|
170
|
+
- uses: hynek/setup-cached-uv@34e35d30f1ebc7421a5cc733bca38dcc62603960 # v2.6.0
|
|
173
171
|
|
|
174
172
|
- name: Start PostgreSQL
|
|
175
173
|
# The README examples connect to a real database, so the doctests need
|
|
@@ -186,7 +184,7 @@ jobs:
|
|
|
186
184
|
until sudo -u postgres pg_isready -q; do sleep 1; done
|
|
187
185
|
|
|
188
186
|
- run: >
|
|
189
|
-
uvx --with tox-uv
|
|
187
|
+
uvx --with tox-uv-bare
|
|
190
188
|
tox run -e docs-doctests
|
|
191
189
|
|
|
192
190
|
docs-build:
|
|
@@ -200,14 +198,13 @@ jobs:
|
|
|
200
198
|
name: Packages
|
|
201
199
|
path: dist
|
|
202
200
|
- run: tar xf dist/*.tar.gz --strip-components=1
|
|
203
|
-
- uses: actions/setup-python@
|
|
201
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
204
202
|
with:
|
|
205
|
-
# Keep in sync with tox.ini's base_python_file.
|
|
206
203
|
python-version-file: .python-version
|
|
207
|
-
- uses: hynek/setup-cached-uv@
|
|
204
|
+
- uses: hynek/setup-cached-uv@34e35d30f1ebc7421a5cc733bca38dcc62603960 # v2.6.0
|
|
208
205
|
|
|
209
206
|
- run: >
|
|
210
|
-
uvx --with tox-uv
|
|
207
|
+
uvx --with tox-uv-bare
|
|
211
208
|
tox run -e docs-build -- --strict
|
|
212
209
|
|
|
213
210
|
install-dev:
|
|
@@ -215,13 +212,13 @@ jobs:
|
|
|
215
212
|
runs-on: ubuntu-latest
|
|
216
213
|
|
|
217
214
|
steps:
|
|
218
|
-
- uses: actions/checkout@
|
|
215
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
219
216
|
with:
|
|
220
217
|
persist-credentials: false
|
|
221
|
-
- uses: actions/setup-python@
|
|
218
|
+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
|
222
219
|
with:
|
|
223
220
|
python-version-file: .python-version
|
|
224
|
-
- uses: hynek/setup-cached-uv@
|
|
221
|
+
- uses: hynek/setup-cached-uv@34e35d30f1ebc7421a5cc733bca38dcc62603960 # v2.6.0
|
|
225
222
|
|
|
226
223
|
- run: uv venv
|
|
227
224
|
- run: uv pip install -e . --group dev
|
|
@@ -243,6 +240,6 @@ jobs:
|
|
|
243
240
|
|
|
244
241
|
steps:
|
|
245
242
|
- name: Decide whether the needed jobs succeeded or failed
|
|
246
|
-
uses: re-actors/alls-green@
|
|
243
|
+
uses: re-actors/alls-green@b5b5b37504aa4183270bd3d855c52a67f212be35 # v1.3.0
|
|
247
244
|
with:
|
|
248
245
|
jobs: ${{ toJSON(needs) }}
|
|
@@ -26,17 +26,17 @@ jobs:
|
|
|
26
26
|
|
|
27
27
|
steps:
|
|
28
28
|
- name: Checkout repository
|
|
29
|
-
uses: actions/checkout@
|
|
29
|
+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
30
30
|
with:
|
|
31
31
|
persist-credentials: false
|
|
32
32
|
|
|
33
33
|
- name: Initialize CodeQL
|
|
34
|
-
uses: github/codeql-action/init@
|
|
34
|
+
uses: github/codeql-action/init@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2
|
|
35
35
|
with:
|
|
36
36
|
languages: ${{ matrix.language }}
|
|
37
37
|
|
|
38
38
|
- name: Autobuild
|
|
39
|
-
uses: github/codeql-action/autobuild@
|
|
39
|
+
uses: github/codeql-action/autobuild@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2
|
|
40
40
|
|
|
41
41
|
- name: Perform CodeQL Analysis
|
|
42
|
-
uses: github/codeql-action/analyze@
|
|
42
|
+
uses: github/codeql-action/analyze@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2
|
|
@@ -26,12 +26,12 @@ jobs:
|
|
|
26
26
|
id-token: write # necessary for GitHub attestations
|
|
27
27
|
|
|
28
28
|
steps:
|
|
29
|
-
- uses: actions/checkout@
|
|
29
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
30
30
|
with:
|
|
31
31
|
fetch-depth: 0
|
|
32
32
|
persist-credentials: false
|
|
33
33
|
|
|
34
|
-
- uses: hynek/build-and-inspect-python-package@
|
|
34
|
+
- uses: hynek/build-and-inspect-python-package@2abe76da66d0a6a4a227101f9348ee855797cfa5 # v3.0.1
|
|
35
35
|
with:
|
|
36
36
|
attest-build-provenance-github: 'true'
|
|
37
37
|
|
|
@@ -54,7 +54,7 @@ jobs:
|
|
|
54
54
|
path: dist
|
|
55
55
|
|
|
56
56
|
- name: Upload package to Test PyPI
|
|
57
|
-
uses: pypa/gh-action-pypi-publish@
|
|
57
|
+
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
|
|
58
58
|
with:
|
|
59
59
|
repository-url: https://test.pypi.org/legacy/
|
|
60
60
|
|
|
@@ -77,6 +77,6 @@ jobs:
|
|
|
77
77
|
path: dist
|
|
78
78
|
|
|
79
79
|
- name: Upload package to PyPI
|
|
80
|
-
uses: pypa/gh-action-pypi-publish@
|
|
80
|
+
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
|
|
81
81
|
with:
|
|
82
82
|
attestations: true
|
|
@@ -22,12 +22,12 @@ jobs:
|
|
|
22
22
|
security-events: write # Required for upload-sarif (used by zizmor-action) to upload SARIF files.
|
|
23
23
|
steps:
|
|
24
24
|
- name: Checkout repository
|
|
25
|
-
uses: actions/checkout@
|
|
25
|
+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
26
26
|
with:
|
|
27
27
|
persist-credentials: false
|
|
28
28
|
|
|
29
29
|
- name: Run zizmor 🌈
|
|
30
|
-
uses: zizmorcore/zizmor-action@
|
|
30
|
+
uses: zizmorcore/zizmor-action@cc914d7f3750a2d13d75c7f184a1060aa0e9d482 # v0.6.4
|
|
31
31
|
with:
|
|
32
32
|
persona: pedantic
|
|
33
33
|
...
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
repos:
|
|
3
3
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
4
|
-
rev: v0.
|
|
4
|
+
rev: v0.16.9
|
|
5
5
|
hooks:
|
|
6
6
|
- id: ruff-check
|
|
7
7
|
args: [--fix, --exit-non-zero-on-fix]
|
|
@@ -14,12 +14,12 @@ repos:
|
|
|
14
14
|
args: [tests]
|
|
15
15
|
|
|
16
16
|
- repo: https://github.com/codespell-project/codespell
|
|
17
|
-
rev: v2.4.
|
|
17
|
+
rev: v2.4.3
|
|
18
18
|
hooks:
|
|
19
19
|
- id: codespell
|
|
20
20
|
|
|
21
21
|
- repo: https://github.com/abravalheri/validate-pyproject
|
|
22
|
-
rev:
|
|
22
|
+
rev: "0.26"
|
|
23
23
|
hooks:
|
|
24
24
|
- id: validate-pyproject
|
|
25
25
|
# Optional extra validations from SchemaStore:
|
|
@@ -4,8 +4,9 @@ version: 2
|
|
|
4
4
|
build:
|
|
5
5
|
os: ubuntu-lts-latest
|
|
6
6
|
tools:
|
|
7
|
-
#
|
|
8
|
-
|
|
7
|
+
# Mandatory field. We allow uv to install Python to avoid manual
|
|
8
|
+
# duplication, but latest is usually the correct version.
|
|
9
|
+
python: latest
|
|
9
10
|
jobs:
|
|
10
11
|
create_environment:
|
|
11
12
|
# Need the tags to calculate the version.
|
|
@@ -19,7 +20,7 @@ build:
|
|
|
19
20
|
html:
|
|
20
21
|
# Set canonical URL
|
|
21
22
|
- sed -i "s|https://psycache.hynek.me/|$READTHEDOCS_CANONICAL_URL|g" zensical.toml
|
|
22
|
-
- uvx --with tox-uv tox run -e docs-build
|
|
23
|
+
- uvx --with tox-uv-bare tox run -e docs-build
|
|
23
24
|
# Zensical builds into site/; hand it to Read the Docs.
|
|
24
25
|
# https://docs.readthedocs.com/platform/latest/intro/zensical.html
|
|
25
26
|
- mkdir -p $READTHEDOCS_OUTPUT/html/
|
|
@@ -8,13 +8,28 @@ The **first number** of the version is the year.
|
|
|
8
8
|
The **second number** is incremented with each release, starting at 1 for each year.
|
|
9
9
|
The **third number** is for emergencies when we need to start branches for older releases.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
> This package is currently in beta and looks forward to your feedback.
|
|
13
|
-
> The code is battle-tested, but APIs may change.
|
|
11
|
+
You can find our backwards-compatibility policy [here](https://github.com/hynek/psycache/blob/main/.github/SECURITY.md).
|
|
14
12
|
|
|
15
13
|
<!-- changelog follows -->
|
|
16
14
|
|
|
17
15
|
|
|
16
|
+
## [26.4.0](https://github.com/hynek/psycache/compare/26.3.0...26.4.0) - 2026-09-29
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- *psycache* is now considered stable and the usual [backwards-compatibility](https://github.com/hynek/psycache/blob/main/.github/SECURITY.md) promises apply.
|
|
21
|
+
|
|
22
|
+
- The *schema* parameters of `init_db()`, `PostgresCache`, and `AsyncPostgresCache` and the `--schema` option of `init-db` have been replaced by *table* and `--table`.
|
|
23
|
+
They take the name of the cache table, optionally schema-qualified with a dot (for example, `app_cache.psycache`).
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- sqlalchemy: Imports from `sqlalchemy.ext.asyncio` are now protected using `if TYPE_CHECKING:`.
|
|
29
|
+
This fixes the runtime dependency on *greenlet* on SQLALchemy 2.1+, even if `psycache.sqlalchemy.AsyncSQLAlchemyCachePool` is not used.
|
|
30
|
+
[#11](https://github.com/hynek/psycache/pull/6)
|
|
31
|
+
|
|
32
|
+
|
|
18
33
|
## [26.3.0](https://github.com/hynek/psycache/compare/26.2.0...26.3.0) - 2026-06-26
|
|
19
34
|
|
|
20
35
|
### Added
|
|
@@ -38,7 +53,7 @@ The **third number** is for emergencies when we need to start branches for older
|
|
|
38
53
|
|
|
39
54
|
- Replaced *attrs* by hand-written classes.
|
|
40
55
|
Sadly, the documentation ecosystem is not ready and *dataclasses* are not fit for public APIs.
|
|
41
|
-
This means
|
|
56
|
+
This means Psycopg is the **only** dependency.
|
|
42
57
|
[#3](https://github.com/hynek/psycache/pull/3)
|
|
43
58
|
|
|
44
59
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: psycache
|
|
3
|
-
Version: 26.
|
|
4
|
-
Summary: A
|
|
3
|
+
Version: 26.4.0
|
|
4
|
+
Summary: A Psycopg-backed PostgreSQL cache
|
|
5
5
|
Project-URL: Documentation, https://psycache.hynek.me/
|
|
6
6
|
Project-URL: Changelog, https://github.com/hynek/psycache/blob/main/CHANGELOG.md
|
|
7
7
|
Project-URL: GitHub, https://github.com/hynek/psycache
|
|
@@ -14,7 +14,7 @@ Author-email: Hynek Schlawack <hs@ox.cx>
|
|
|
14
14
|
License-Expression: MIT
|
|
15
15
|
License-File: LICENSE
|
|
16
16
|
Keywords: cache,postgres,postgresql,psycopg
|
|
17
|
-
Classifier: Development Status ::
|
|
17
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.13
|
|
@@ -22,7 +22,7 @@ Classifier: Programming Language :: Python :: 3.14
|
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.15
|
|
23
23
|
Classifier: Typing :: Typed
|
|
24
24
|
Requires-Python: >=3.11
|
|
25
|
-
Requires-Dist: psycopg
|
|
25
|
+
Requires-Dist: psycopg>3
|
|
26
26
|
Provides-Extra: pool
|
|
27
27
|
Requires-Dist: psycopg-pool; extra == 'pool'
|
|
28
28
|
Provides-Extra: prometheus
|
|
@@ -35,15 +35,11 @@ Provides-Extra: sqlalchemy-asyncio
|
|
|
35
35
|
Requires-Dist: sqlalchemy[asyncio]; extra == 'sqlalchemy-asyncio'
|
|
36
36
|
Description-Content-Type: text/markdown
|
|
37
37
|
|
|
38
|
-
# *psycache
|
|
38
|
+
# *psycache*
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
[](https://psycache.hynek.me/)
|
|
42
|
-
[](https://pypi.org/project/psycache/)
|
|
43
|
-
[](https://github.com/hynek/psycache/blob/main/.github/AI_POLICY.md)
|
|
40
|
+
*A Psycopg-backed PostgreSQL cache*
|
|
44
41
|
|
|
45
|
-
|
|
46
|
-
A key-value cache that stores JSON in PostgreSQL through [*psycopg*](https://www.psycopg.org/) 3, with TTL-based expiration and pluggable instrumentation.
|
|
42
|
+
A key-value cache that stores JSON in PostgreSQL through [Psycopg](https://www.psycopg.org/) 3, with TTL-based expiration and pluggable instrumentation.
|
|
47
43
|
|
|
48
44
|
- Sync and async ✔︎
|
|
49
45
|
- Type-safe ✔︎
|
|
@@ -56,6 +52,8 @@ A key-value cache that stores JSON in PostgreSQL through [*psycopg*](https://www
|
|
|
56
52
|
It's a great fit when you already have PostgreSQL and need a fast cache without introducing another piece of infrastructure like Redis.
|
|
57
53
|
For example, you can safely share a SQLAlchemy [`Engine`](https://docs.sqlalchemy.org/en/20/core/connections.html#sqlalchemy.engine.Engine) (or [`AsyncEngine`](https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html#sqlalchemy.ext.asyncio.AsyncEngine)) with *psycache*.
|
|
58
54
|
|
|
55
|
+
<!-- --8<-- [end:spiel] -->
|
|
56
|
+
|
|
59
57
|
|
|
60
58
|
## Quick Start
|
|
61
59
|
|
|
@@ -70,7 +68,7 @@ $ uv pip install "psycache[sqlalchemy]"
|
|
|
70
68
|
Initialize the cache table once[^cli] then store and retrieve JSON with a TTL:
|
|
71
69
|
|
|
72
70
|
[^cli]: `python -Im psycache init-db <dsn>` does the same from the shell.
|
|
73
|
-
Add `--
|
|
71
|
+
Add `--table <table>` to use a different table name, optionally schema-qualified with a dot.
|
|
74
72
|
Omit `<dsn>` to print the SQL.
|
|
75
73
|
|
|
76
74
|
```python
|
|
@@ -83,6 +81,7 @@ import psycache
|
|
|
83
81
|
from psycache import PostgresCache
|
|
84
82
|
from psycache.sqlalchemy import SQLAlchemyCachePool
|
|
85
83
|
|
|
84
|
+
|
|
86
85
|
with psycopg.connect(
|
|
87
86
|
"postgresql://psycache@127.0.0.1/psycache", autocommit=True
|
|
88
87
|
) as conn:
|
|
@@ -104,10 +103,30 @@ engine.dispose()
|
|
|
104
103
|
Full documentation lives at **<https://psycache.hynek.me/>**.
|
|
105
104
|
|
|
106
105
|
|
|
107
|
-
|
|
106
|
+
## Release Information
|
|
107
|
+
|
|
108
|
+
### Changed
|
|
109
|
+
|
|
110
|
+
- *psycache* is now considered stable and the usual [backwards-compatibility](https://github.com/hynek/psycache/blob/main/.github/SECURITY.md) promises apply.
|
|
111
|
+
|
|
112
|
+
- The *schema* parameters of `init_db()`, `PostgresCache`, and `AsyncPostgresCache` and the `--schema` option of `init-db` have been replaced by *table* and `--table`.
|
|
113
|
+
They take the name of the cache table, optionally schema-qualified with a dot (for example, `app_cache.psycache`).
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
### Fixed
|
|
117
|
+
|
|
118
|
+
- sqlalchemy: Imports from `sqlalchemy.ext.asyncio` are now protected using `if TYPE_CHECKING:`.
|
|
119
|
+
This fixes the runtime dependency on *greenlet* on SQLALchemy 2.1+, even if `psycache.sqlalchemy.AsyncSQLAlchemyCachePool` is not used.
|
|
120
|
+
[#11](https://github.com/hynek/psycache/pull/6)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
[Full Changelog →](https://github.com/hynek/psycache/blob/main/CHANGELOG.md)
|
|
126
|
+
|
|
127
|
+
|
|
108
128
|
## Credits
|
|
109
129
|
|
|
110
130
|
*psycache* is written by [Hynek Schlawack](https://hynek.me/) and distributed under the terms of the [MIT license](https://choosealicense.com/licenses/mit/).
|
|
111
131
|
|
|
112
|
-
The development is kindly supported by my employer [Variomedia AG](https://www.variomedia.de/) and all my fabulous [GitHub Sponsors](https://github.com/sponsors/hynek).
|
|
113
|
-
<!-- --8<-- [end:credits] -->
|
|
132
|
+
The development is kindly supported by my employer [Variomedia AG](https://www.variomedia.de/) and all my fabulous [GitHub Sponsors](https://github.com/sponsors/hynek).
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- --8<-- [start:header] -->
|
|
2
|
+
# *psycache*
|
|
3
|
+
|
|
4
|
+
*A Psycopg-backed PostgreSQL cache*
|
|
5
|
+
<!-- --8<-- [end:header] -->
|
|
2
6
|
|
|
3
7
|
[](https://github.com/hynek/psycache/blob/main/LICENSE)
|
|
4
|
-
[](https://psycache.hynek.me/)
|
|
5
9
|
[](https://pypi.org/project/psycache/)
|
|
6
10
|
[](https://github.com/hynek/psycache/blob/main/.github/AI_POLICY.md)
|
|
7
11
|
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
<!-- --8<-- [start:spiel] -->
|
|
14
|
+
A key-value cache that stores JSON in PostgreSQL through [Psycopg](https://www.psycopg.org/) 3, with TTL-based expiration and pluggable instrumentation.
|
|
10
15
|
|
|
11
16
|
- Sync and async ✔︎
|
|
12
17
|
- Type-safe ✔︎
|
|
@@ -19,6 +24,8 @@ A key-value cache that stores JSON in PostgreSQL through [*psycopg*](https://www
|
|
|
19
24
|
It's a great fit when you already have PostgreSQL and need a fast cache without introducing another piece of infrastructure like Redis.
|
|
20
25
|
For example, you can safely share a SQLAlchemy [`Engine`](https://docs.sqlalchemy.org/en/20/core/connections.html#sqlalchemy.engine.Engine) (or [`AsyncEngine`](https://docs.sqlalchemy.org/en/20/orm/extensions/asyncio.html#sqlalchemy.ext.asyncio.AsyncEngine)) with *psycache*.
|
|
21
26
|
|
|
27
|
+
<!-- --8<-- [end:spiel] -->
|
|
28
|
+
|
|
22
29
|
|
|
23
30
|
## Quick Start
|
|
24
31
|
|
|
@@ -33,7 +40,7 @@ $ uv pip install "psycache[sqlalchemy]"
|
|
|
33
40
|
Initialize the cache table once[^cli] then store and retrieve JSON with a TTL:
|
|
34
41
|
|
|
35
42
|
[^cli]: `python -Im psycache init-db <dsn>` does the same from the shell.
|
|
36
|
-
Add `--
|
|
43
|
+
Add `--table <table>` to use a different table name, optionally schema-qualified with a dot.
|
|
37
44
|
Omit `<dsn>` to print the SQL.
|
|
38
45
|
|
|
39
46
|
```python
|
|
@@ -46,6 +53,7 @@ import psycache
|
|
|
46
53
|
from psycache import PostgresCache
|
|
47
54
|
from psycache.sqlalchemy import SQLAlchemyCachePool
|
|
48
55
|
|
|
56
|
+
|
|
49
57
|
with psycopg.connect(
|
|
50
58
|
"postgresql://psycache@127.0.0.1/psycache", autocommit=True
|
|
51
59
|
) as conn:
|
|
@@ -26,6 +26,14 @@ collect_ignore = [
|
|
|
26
26
|
if importlib.util.find_spec(name) is None
|
|
27
27
|
]
|
|
28
28
|
|
|
29
|
+
# SQLAlchemy imports greenlet lazily, so sqlalchemy.ext.asyncio is importable
|
|
30
|
+
# without it, but unusable.
|
|
31
|
+
try:
|
|
32
|
+
import greenlet # noqa: F401
|
|
33
|
+
import sqlalchemy.ext.asyncio # noqa: F401
|
|
34
|
+
except ImportError:
|
|
35
|
+
collect_ignore.append("tests/test_sqlalchemy_async.py")
|
|
36
|
+
|
|
29
37
|
# The docs are CommonMark/Material (Zensical), so use the Markdown parsers.
|
|
30
38
|
# Executable examples use plain ```python fences; illustrative snippets are
|
|
31
39
|
# preceded by an HTML comment <!-- skip: next -->.
|
|
@@ -44,6 +52,11 @@ def _db_dsn():
|
|
|
44
52
|
return "postgresql://psycache@127.0.0.1/psycache"
|
|
45
53
|
|
|
46
54
|
|
|
55
|
+
@pytest.fixture(name="sqla_url")
|
|
56
|
+
def _sqla_url(db_dsn):
|
|
57
|
+
return db_dsn.replace("postgresql", "postgresql+psycopg")
|
|
58
|
+
|
|
59
|
+
|
|
47
60
|
@pytest.fixture(name="psycache_database", scope="session", autouse=True)
|
|
48
61
|
def _psycache_database(db_dsn) -> None:
|
|
49
62
|
"""
|
|
@@ -52,9 +52,12 @@ from psycache import AsyncPostgresCache
|
|
|
52
52
|
from psycache.sqlalchemy import AsyncSQLAlchemyCachePool
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
aengine = create_async_engine(
|
|
55
|
+
aengine = create_async_engine(
|
|
56
|
+
"postgresql+psycopg://psycache@127.0.0.1/psycache"
|
|
57
|
+
)
|
|
56
58
|
acache = AsyncPostgresCache(AsyncSQLAlchemyCachePool(aengine))
|
|
57
59
|
|
|
60
|
+
|
|
58
61
|
async def main():
|
|
59
62
|
async with acache.start_cleanup_task(interval=60):
|
|
60
63
|
... # your application runs here
|
|
@@ -65,5 +68,60 @@ async def main():
|
|
|
65
68
|
finally:
|
|
66
69
|
await svc.stop()
|
|
67
70
|
|
|
71
|
+
|
|
68
72
|
asyncio.run(main())
|
|
69
73
|
```
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## ... or an elected *pgbg* service { #pgbg }
|
|
77
|
+
|
|
78
|
+
Both helpers above run the cleanup in *every* process that starts them.
|
|
79
|
+
That's harmless, because deleting expired rows is idempotent.
|
|
80
|
+
But if you run many instances of your application, it's wasteful, because all of them delete the same rows at the same interval, and most of them find nothing to do.
|
|
81
|
+
|
|
82
|
+
[*pgbg*](https://pgbg.hynek.me/) solves this with PostgreSQL-based **leader election**:
|
|
83
|
+
many processes can start the same service, but only one of them runs it at a time.
|
|
84
|
+
On top of that, *pgbg* supervises the thread and restarts it after a crash.
|
|
85
|
+
|
|
86
|
+
Wrap [`PostgresCache.cleanup_expired()`][psycache.PostgresCache.cleanup_expired] in a work unit and start it as an elected service (example requires `pgbg[sqlalchemy]`, but works with raw Psycopg, too):
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
import bgt
|
|
90
|
+
import pgbg
|
|
91
|
+
|
|
92
|
+
from pgbg.sqlalchemy import start_elected_service
|
|
93
|
+
from sqlalchemy import create_engine
|
|
94
|
+
|
|
95
|
+
from psycache import PostgresCache
|
|
96
|
+
from psycache.sqlalchemy import SQLAlchemyCachePool
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
engine = create_engine("postgresql+psycopg://psycache@127.0.0.1/psycache")
|
|
100
|
+
cache = PostgresCache(SQLAlchemyCachePool(engine))
|
|
101
|
+
|
|
102
|
+
# *pgbg* requires a lease database; you only do this once.
|
|
103
|
+
with engine.connect() as conn:
|
|
104
|
+
pgbg.init_db(conn.connection.driver_connection)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def cleanup_cache() -> bool:
|
|
108
|
+
cache.cleanup_expired()
|
|
109
|
+
|
|
110
|
+
return False # done until the next interval
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
with start_elected_service(
|
|
114
|
+
bgt.as_work_factory(cleanup_cache),
|
|
115
|
+
engine,
|
|
116
|
+
name="psycache-cleanup",
|
|
117
|
+
worker_id="worker-01.example.internal", # unique per process
|
|
118
|
+
wakeup=bgt.IntervalOnlyWakeup(),
|
|
119
|
+
interval=60,
|
|
120
|
+
):
|
|
121
|
+
... # your application runs here
|
|
122
|
+
|
|
123
|
+
engine.dispose()
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
*pgbg* is thread-based and runs plain, non-async functions.
|
|
127
|
+
So pair it with the synchronous [`PostgresCache`][psycache.PostgresCache], even if the rest of your application is async.
|