rust-py-cache 0.2.2__tar.gz → 0.2.3__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.
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/.github/workflows/ci.yml +24 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/.github/workflows/release.yml +30 -6
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/CHANGELOG.md +31 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/Cargo.lock +1 -1
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/Cargo.toml +2 -1
- rust_py_cache-0.2.3/LICENSE +21 -0
- rust_py_cache-0.2.3/Makefile +68 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/PKG-INFO +3 -3
- rust_py_cache-0.2.3/clippy.toml +11 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/pyproject.toml +12 -4
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/python/rust_py_cache/__init__.py +1 -1
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/src/cache.rs +5 -1
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/src/lib.rs +1 -6
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/.gitignore +0 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/PUBLISHING.md +0 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/README.md +0 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/ROADMAP.md +0 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/examples/django_example.py +0 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/examples/fastapi_example.py +0 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/python/rust_py_cache/decorators.py +0 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/src/entry.rs +0 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/src/stats.rs +0 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/src/sweeper.rs +0 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/src/ttl.rs +0 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/tests/test_cache_basic.py +0 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/tests/test_delete.py +0 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/tests/test_eviction.py +0 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/tests/test_features.py +0 -0
- {rust_py_cache-0.2.2 → rust_py_cache-0.2.3}/tests/test_set_get.py +0 -0
|
@@ -7,6 +7,30 @@ on:
|
|
|
7
7
|
workflow_dispatch:
|
|
8
8
|
|
|
9
9
|
jobs:
|
|
10
|
+
# O lint faz parte do portão de release, não de um workflow paralelo.
|
|
11
|
+
# Nos repositórios de workflow único, um `lint` vermelho ao lado de uma
|
|
12
|
+
# publicação bem-sucedida seria ruído difícil de ler — a leitura passa a ser
|
|
13
|
+
# inequívoca: vermelho significa que não publicou.
|
|
14
|
+
#
|
|
15
|
+
# A toolchain é fixa, não "stable": com `-D warnings`, um clippy mais novo
|
|
16
|
+
# no runner reprova código que ninguém tocou, e a CI ficaria vermelha por
|
|
17
|
+
# conta do calendário. Subir este número vira uma mudança deliberada.
|
|
18
|
+
lint:
|
|
19
|
+
name: fmt + clippy
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v4
|
|
23
|
+
- uses: dtolnay/rust-toolchain@1.88.0
|
|
24
|
+
with:
|
|
25
|
+
components: rustfmt, clippy
|
|
26
|
+
- uses: Swatinem/rust-cache@v2
|
|
27
|
+
- name: cargo fmt
|
|
28
|
+
run: cargo fmt --all -- --check
|
|
29
|
+
# clippy só checa tipos, não linka, então --all-features é seguro aqui
|
|
30
|
+
# (diferente do `cargo test`, que precisa de --no-default-features).
|
|
31
|
+
- name: cargo clippy
|
|
32
|
+
run: cargo clippy --all-targets --all-features -- -D warnings
|
|
33
|
+
|
|
10
34
|
test:
|
|
11
35
|
name: cargo test + pytest
|
|
12
36
|
runs-on: ${{ matrix.os }}
|
|
@@ -17,6 +17,30 @@ permissions:
|
|
|
17
17
|
contents: read
|
|
18
18
|
|
|
19
19
|
jobs:
|
|
20
|
+
# O lint faz parte do portão de release, não de um workflow paralelo.
|
|
21
|
+
# Nos repositórios de workflow único, um `lint` vermelho ao lado de uma
|
|
22
|
+
# publicação bem-sucedida seria ruído difícil de ler — a leitura passa a ser
|
|
23
|
+
# inequívoca: vermelho significa que não publicou.
|
|
24
|
+
#
|
|
25
|
+
# A toolchain é fixa, não "stable": com `-D warnings`, um clippy mais novo
|
|
26
|
+
# no runner reprova código que ninguém tocou, e a CI ficaria vermelha por
|
|
27
|
+
# conta do calendário. Subir este número vira uma mudança deliberada.
|
|
28
|
+
lint:
|
|
29
|
+
name: fmt + clippy
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
- uses: dtolnay/rust-toolchain@1.88.0
|
|
34
|
+
with:
|
|
35
|
+
components: rustfmt, clippy
|
|
36
|
+
- uses: Swatinem/rust-cache@v2
|
|
37
|
+
- name: cargo fmt
|
|
38
|
+
run: cargo fmt --all -- --check
|
|
39
|
+
# clippy só checa tipos, não linka, então --all-features é seguro aqui
|
|
40
|
+
# (diferente do `cargo test`, que precisa de --no-default-features).
|
|
41
|
+
- name: cargo clippy
|
|
42
|
+
run: cargo clippy --all-targets --all-features -- -D warnings
|
|
43
|
+
|
|
20
44
|
test:
|
|
21
45
|
name: Test (Rust + Python)
|
|
22
46
|
runs-on: ubuntu-latest
|
|
@@ -43,7 +67,7 @@ jobs:
|
|
|
43
67
|
linux:
|
|
44
68
|
runs-on: ubuntu-latest
|
|
45
69
|
if: startsWith(github.ref, 'refs/tags/')
|
|
46
|
-
needs: test
|
|
70
|
+
needs: [test, lint]
|
|
47
71
|
strategy:
|
|
48
72
|
matrix:
|
|
49
73
|
target: [x86_64, aarch64]
|
|
@@ -64,7 +88,7 @@ jobs:
|
|
|
64
88
|
musllinux:
|
|
65
89
|
runs-on: ubuntu-latest
|
|
66
90
|
if: startsWith(github.ref, 'refs/tags/')
|
|
67
|
-
needs: test
|
|
91
|
+
needs: [test, lint]
|
|
68
92
|
strategy:
|
|
69
93
|
matrix:
|
|
70
94
|
target: [x86_64, aarch64]
|
|
@@ -83,7 +107,7 @@ jobs:
|
|
|
83
107
|
windows:
|
|
84
108
|
runs-on: windows-latest
|
|
85
109
|
if: startsWith(github.ref, 'refs/tags/')
|
|
86
|
-
needs: test
|
|
110
|
+
needs: [test, lint]
|
|
87
111
|
steps:
|
|
88
112
|
- uses: actions/checkout@v4
|
|
89
113
|
- uses: actions/setup-python@v5
|
|
@@ -101,7 +125,7 @@ jobs:
|
|
|
101
125
|
macos:
|
|
102
126
|
runs-on: macos-latest
|
|
103
127
|
if: startsWith(github.ref, 'refs/tags/')
|
|
104
|
-
needs: test
|
|
128
|
+
needs: [test, lint]
|
|
105
129
|
strategy:
|
|
106
130
|
matrix:
|
|
107
131
|
target: [x86_64, aarch64]
|
|
@@ -119,7 +143,7 @@ jobs:
|
|
|
119
143
|
sdist:
|
|
120
144
|
runs-on: ubuntu-latest
|
|
121
145
|
if: startsWith(github.ref, 'refs/tags/')
|
|
122
|
-
needs: test
|
|
146
|
+
needs: [test, lint]
|
|
123
147
|
steps:
|
|
124
148
|
- uses: actions/checkout@v4
|
|
125
149
|
- uses: PyO3/maturin-action@v1
|
|
@@ -136,7 +160,7 @@ jobs:
|
|
|
136
160
|
# Guarda além do gatilho: sem ela, um `workflow_dispatch` a partir de um
|
|
137
161
|
# branch publicaria no PyPI.
|
|
138
162
|
if: startsWith(github.ref, 'refs/tags/')
|
|
139
|
-
needs: [test, linux, musllinux, windows, macos, sdist]
|
|
163
|
+
needs: [lint, test, linux, musllinux, windows, macos, sdist]
|
|
140
164
|
runs-on: ubuntu-latest
|
|
141
165
|
environment: pypi
|
|
142
166
|
permissions:
|
|
@@ -5,6 +5,37 @@ Todas as mudanças relevantes deste projeto são registradas aqui.
|
|
|
5
5
|
O formato segue [Keep a Changelog](https://keepachangelog.com/pt-BR/1.1.0/),
|
|
6
6
|
e o versionamento segue [SemVer](https://semver.org/lang/pt-BR/).
|
|
7
7
|
|
|
8
|
+
## [0.2.3] — não publicada
|
|
9
|
+
|
|
10
|
+
Versão de empacotamento e qualidade: nada muda no comportamento da biblioteca.
|
|
11
|
+
|
|
12
|
+
### Adicionado
|
|
13
|
+
|
|
14
|
+
- **`LICENSE`** (MIT). O projeto declarava MIT no `pyproject.toml` desde sempre,
|
|
15
|
+
mas o texto da licença não existia no repositório nem na wheel (**P1-4**).
|
|
16
|
+
- **`clippy.toml` e `Makefile`** compartilhados com os outros quatro `rust_py_*`,
|
|
17
|
+
e um job `lint` (`cargo fmt --check` + `cargo clippy -D warnings`) no `ci.yml`
|
|
18
|
+
e no `release.yml` — este barrando a publicação, como o `test` já barrava
|
|
19
|
+
(**P1-6**). O `cargo clippy` já estava limpo aqui; foi o único dos cinco.
|
|
20
|
+
|
|
21
|
+
### Corrigido
|
|
22
|
+
|
|
23
|
+
- **Metadado de licença ausente no PyPI.** O `pyproject.toml` usava
|
|
24
|
+
`license = { text = "MIT" }`, forma legada que o Metadata 2.4 depreca. Passou
|
|
25
|
+
para a do PEP 639 (`license = "MIT"` + `license-files = ["LICENSE"]`), e o
|
|
26
|
+
classifier `License :: OSI Approved` saiu — ele é mutuamente exclusivo com
|
|
27
|
+
`License-Expression`. A 0.2.2 no PyPI mostra `license: MIT` no campo legado e
|
|
28
|
+
`license_expression: null`; a partir daqui é o contrário, que é o correto.
|
|
29
|
+
|
|
30
|
+
- **Piso da maturin subiu para 1.14** no `[build-system]`. Era `>=1.7`, e
|
|
31
|
+
versões anteriores não emitem `License-Expression` — foi essa, e não a forma
|
|
32
|
+
no `pyproject`, a causa raiz do metadado faltando.
|
|
33
|
+
|
|
34
|
+
### Declarado como Cargo
|
|
35
|
+
|
|
36
|
+
- `Cargo.toml` não tinha campo `license` nenhum. Agora tem `license = "MIT"`,
|
|
37
|
+
como os outros quatro.
|
|
38
|
+
|
|
8
39
|
## [0.2.2] - 2026-08-11
|
|
9
40
|
|
|
10
41
|
Release de infraestrutura: nada muda no comportamento da biblioteca, mas muda
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Roberto Lima
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Makefile compartilhado dos `rust_py_*`.
|
|
2
|
+
#
|
|
3
|
+
# Existe para que a CI e a pessoa rodem exatamente o mesmo comando. Quando o
|
|
4
|
+
# lint da CI diverge do lint local, quem perde é sempre quem abriu o PR.
|
|
5
|
+
#
|
|
6
|
+
# A toolchain NÃO é fixada por `rust-toolchain.toml` de propósito: esse arquivo
|
|
7
|
+
# vale para toda invocação do cargo, inclusive a dos containers manylinux do
|
|
8
|
+
# release, e um download de toolchain no meio de uma publicação no PyPI é risco
|
|
9
|
+
# sem contrapartida. A fixação vive no job de lint da CI, que é onde
|
|
10
|
+
# `-D warnings` realmente morde. Localmente, use uma stable recente.
|
|
11
|
+
|
|
12
|
+
PYTHON ?= python3
|
|
13
|
+
|
|
14
|
+
# Fixa qual Python o pyo3 usa na compilação. Sem isto ele pega o primeiro do
|
|
15
|
+
# PATH, que pode não ser o mesmo do `make dev` — e aí o binário de teste linka
|
|
16
|
+
# contra uma libpython e o pytest roda contra outra.
|
|
17
|
+
export PYO3_PYTHON ?= $(PYTHON)
|
|
18
|
+
|
|
19
|
+
# No macOS o binário de `cargo test` carrega a libpython em runtime, e o dyld
|
|
20
|
+
# não a encontra sozinho: o erro é `Library not loaded: @rpath/libpython3.X.dylib`,
|
|
21
|
+
# em SIGABRT, depois de compilar com sucesso — parece falha de teste e não é.
|
|
22
|
+
# Os caminhos padrão entram junto porque definir DYLD_FALLBACK_LIBRARY_PATH
|
|
23
|
+
# *substitui* a lista default do dyld em vez de acrescentar a ela (senão o
|
|
24
|
+
# erro seguinte é libiconv.2.dylib).
|
|
25
|
+
PY_LIBDIR := $(shell $(PYTHON) -c 'import sysconfig; print(sysconfig.get_config_var("LIBDIR") or "")' 2>/dev/null)
|
|
26
|
+
export DYLD_FALLBACK_LIBRARY_PATH := $(PY_LIBDIR):/opt/homebrew/lib:/usr/local/lib:/usr/lib
|
|
27
|
+
|
|
28
|
+
.PHONY: help dev test lint fmt clippy test-rust test-python clean
|
|
29
|
+
|
|
30
|
+
help:
|
|
31
|
+
@echo "make dev instala o pacote em modo editável com os extras de dev"
|
|
32
|
+
@echo "make test cargo test + pytest"
|
|
33
|
+
@echo "make lint cargo fmt --check + cargo clippy -D warnings"
|
|
34
|
+
@echo "make fmt aplica a formatação (escreve nos arquivos)"
|
|
35
|
+
|
|
36
|
+
# `pip install` aciona o backend maturin, compila a extensão e instala.
|
|
37
|
+
# Ao contrário de `maturin develop`, não exige um virtualenv ativo — que é
|
|
38
|
+
# exatamente a armadilha que custou um release do monitor (ver P1-9).
|
|
39
|
+
dev:
|
|
40
|
+
$(PYTHON) -m pip install --upgrade pip
|
|
41
|
+
$(PYTHON) -m pip install -e ".[dev]"
|
|
42
|
+
|
|
43
|
+
test: test-rust test-python
|
|
44
|
+
|
|
45
|
+
# --no-default-features desliga `extension-module`, que impede o binário de
|
|
46
|
+
# teste de linkar contra a libpython no Linux. --lib porque os testes de
|
|
47
|
+
# integração precisam do módulo nativo, e esses ficam do lado Python.
|
|
48
|
+
test-rust:
|
|
49
|
+
cargo test --no-default-features --lib
|
|
50
|
+
|
|
51
|
+
test-python:
|
|
52
|
+
pytest -q
|
|
53
|
+
|
|
54
|
+
lint: fmt-check clippy
|
|
55
|
+
|
|
56
|
+
.PHONY: fmt-check
|
|
57
|
+
fmt-check:
|
|
58
|
+
cargo fmt --all -- --check
|
|
59
|
+
|
|
60
|
+
clippy:
|
|
61
|
+
cargo clippy --all-targets --all-features -- -D warnings
|
|
62
|
+
|
|
63
|
+
fmt:
|
|
64
|
+
cargo fmt --all
|
|
65
|
+
|
|
66
|
+
clean:
|
|
67
|
+
cargo clean
|
|
68
|
+
rm -rf dist build *.egg-info .pytest_cache
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rust-py-cache
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: 3
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
7
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
8
7
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
9
8
|
Classifier: Topic :: Database
|
|
10
9
|
Classifier: Topic :: System :: Distributed Computing
|
|
11
10
|
Requires-Dist: pytest>=7.0 ; extra == 'dev'
|
|
12
11
|
Requires-Dist: maturin>=1.7 ; extra == 'dev'
|
|
13
12
|
Provides-Extra: dev
|
|
13
|
+
License-File: LICENSE
|
|
14
14
|
Summary: An ultra-fast local cache for Python, powered by Rust.
|
|
15
15
|
Keywords: cache,rust,pyo3,ttl,performance
|
|
16
16
|
Author-email: Roberto Lima <robertolima.izphera@gmail.com>
|
|
17
|
-
License: MIT
|
|
17
|
+
License-Expression: MIT
|
|
18
18
|
Requires-Python: >=3.10
|
|
19
19
|
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
20
20
|
Project-URL: Homepage, https://github.com/robertolima/rust-py-cache
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Configuração compartilhada do clippy para os cinco `rust_py_*`.
|
|
2
|
+
#
|
|
3
|
+
# O padrão do clippy para `too_many_arguments` é 7. Estes projetos expõem
|
|
4
|
+
# construtores PyO3 que espelham a assinatura Python — `add_job()` do
|
|
5
|
+
# scheduler leva 8 parâmetros porque a API pública leva 8 (retry_backoff,
|
|
6
|
+
# timeout, max_instances e afins). Reagrupar em struct para agradar o lint
|
|
7
|
+
# pioraria a API do lado Python, que é a que o usuário vê.
|
|
8
|
+
#
|
|
9
|
+
# O teto sobe para 10 em vez de o lint ser desligado: acima de 10 o aviso
|
|
10
|
+
# volta a ser informação útil.
|
|
11
|
+
too-many-arguments-threshold = 10
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
|
|
2
|
+
# Piso 1.14 de propósito: versões anteriores da maturin não emitem o
|
|
3
|
+
# `License-Expression` do PEP 639, e o resultado é uma release publicada
|
|
4
|
+
# no PyPI sem metadado de licença nenhum — só o classifier. Foi o que
|
|
5
|
+
# aconteceu com audit 0.3.2, monitor 0.4.1 e rate_limit 0.2.1 (ver P1-4).
|
|
6
|
+
requires = ["maturin>=1.14,<2.0"]
|
|
3
7
|
build-backend = "maturin"
|
|
4
8
|
|
|
5
9
|
[project]
|
|
6
10
|
name = "rust-py-cache"
|
|
7
|
-
version = "0.2.
|
|
11
|
+
version = "0.2.3"
|
|
8
12
|
description = "An ultra-fast local cache for Python, powered by Rust."
|
|
9
13
|
readme = "README.md"
|
|
10
14
|
requires-python = ">=3.10"
|
|
11
|
-
|
|
15
|
+
# Forma do PEP 639: expressão SPDX + arquivos de licença declarados.
|
|
16
|
+
# O classifier "License :: OSI Approved" saiu de propósito — é deprecado
|
|
17
|
+
# quando existe License-Expression, e os dois juntos são mutuamente
|
|
18
|
+
# exclusivos no Metadata 2.4.
|
|
19
|
+
license = "MIT"
|
|
20
|
+
license-files = ["LICENSE"]
|
|
12
21
|
authors = [{ name = "Roberto Lima", email = "robertolima.izphera@gmail.com" }]
|
|
13
22
|
keywords = ["cache", "rust", "pyo3", "ttl", "performance"]
|
|
14
23
|
classifiers = [
|
|
15
24
|
"Programming Language :: Rust",
|
|
16
25
|
"Programming Language :: Python :: 3",
|
|
17
26
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
18
|
-
"License :: OSI Approved :: MIT License",
|
|
19
27
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
20
28
|
"Topic :: Database",
|
|
21
29
|
"Topic :: System :: Distributed Computing",
|
|
@@ -187,7 +187,11 @@ impl RustCache {
|
|
|
187
187
|
|
|
188
188
|
let mut removed = 0u64;
|
|
189
189
|
for key in expired {
|
|
190
|
-
if self
|
|
190
|
+
if self
|
|
191
|
+
.store
|
|
192
|
+
.remove_if(&key, |_, v| v.is_expired(now))
|
|
193
|
+
.is_some()
|
|
194
|
+
{
|
|
191
195
|
removed += 1;
|
|
192
196
|
}
|
|
193
197
|
}
|
|
@@ -155,12 +155,7 @@ impl Cache {
|
|
|
155
155
|
/// - Chave expirada → remove a entrada (expiração lazy) e devolve `default`.
|
|
156
156
|
/// - Caso contrário → o objeto Python original, desserializado por `pickle`.
|
|
157
157
|
#[pyo3(signature = (key, default=None))]
|
|
158
|
-
fn get(
|
|
159
|
-
&self,
|
|
160
|
-
py: Python<'_>,
|
|
161
|
-
key: &str,
|
|
162
|
-
default: Option<Py<PyAny>>,
|
|
163
|
-
) -> PyResult<Py<PyAny>> {
|
|
158
|
+
fn get(&self, py: Python<'_>, key: &str, default: Option<Py<PyAny>>) -> PyResult<Py<PyAny>> {
|
|
164
159
|
match self.inner.get(key, now_ms()) {
|
|
165
160
|
Some(bytes) => loads(py, &bytes),
|
|
166
161
|
None => Ok(default.unwrap_or_else(|| py.None())),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|