diskcache-rs 0.4.10__tar.gz → 0.4.13__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.
Files changed (96) hide show
  1. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/.github/actions/setup-diskcache-rs/action.yml +1 -1
  2. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/.github/workflows/benchmark.yml +1 -1
  3. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/.github/workflows/build-abi3.yml +1 -1
  4. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/.github/workflows/build.yml +1 -2
  5. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/.github/workflows/release.yml +11 -6
  6. diskcache_rs-0.4.13/.release-please-manifest.json +3 -0
  7. diskcache_rs-0.4.13/AGENTS.md +90 -0
  8. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/CHANGELOG.md +38 -0
  9. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/Cargo.lock +40 -45
  10. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/Cargo.toml +3 -3
  11. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/PKG-INFO +1 -1
  12. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/src/eviction.rs +119 -8
  13. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/src/storage/optimized_backend.rs +32 -4
  14. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/conftest.py +9 -3
  15. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_ci_benchmark.py +3 -1
  16. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_performance.py +6 -2
  17. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_special_chars_keys.py +10 -0
  18. diskcache_rs-0.4.10/.release-please-manifest.json +0 -3
  19. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  20. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  21. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/.github/actions/build-and-test/action.yml +0 -0
  22. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/.github/pull_request_template.md +0 -0
  23. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/.github/workflows/ci.yml +0 -0
  24. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/.gitignore +0 -0
  25. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/.pre-commit-config.yaml +0 -0
  26. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/API_COMPATIBILITY.md +0 -0
  27. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/Dockerfile.test +0 -0
  28. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/LICENSE +0 -0
  29. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/README.md +0 -0
  30. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/benchmarks/batch_write_comparison.py +0 -0
  31. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/benchmarks/comprehensive_performance_test.py +0 -0
  32. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/benchmarks/detailed_profiling.py +0 -0
  33. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/benchmarks/final_performance_comparison.py +0 -0
  34. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/benchmarks/high_performance_test.py +0 -0
  35. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/benchmarks/memory_usage_test.py +0 -0
  36. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/benchmarks/micro_benchmark.py +0 -0
  37. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/benchmarks/optimization_validation_test.py +0 -0
  38. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/benchmarks/performance_comparison.py +0 -0
  39. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/benchmarks/pickle_bridge_comparison.py +0 -0
  40. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/benchmarks/precise_benchmark.py +0 -0
  41. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/benchmarks/set_performance_analysis.py +0 -0
  42. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/docker-compose.test.yml +0 -0
  43. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/examples/basic_usage.py +0 -0
  44. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/examples/special_chars_keys_example.py +0 -0
  45. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/justfile +0 -0
  46. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/pyproject.toml +0 -0
  47. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/python/diskcache_rs/__init__.py +0 -0
  48. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/python/diskcache_rs/__init__.pyi +0 -0
  49. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/python/diskcache_rs/_diskcache_rs.pyi +0 -0
  50. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/python/diskcache_rs/cache.py +0 -0
  51. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/python/diskcache_rs/constants.py +0 -0
  52. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/python/diskcache_rs/core.py +0 -0
  53. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/python/diskcache_rs/disk.py +0 -0
  54. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/python/diskcache_rs/djangocache.py +0 -0
  55. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/python/diskcache_rs/fast_cache.py +0 -0
  56. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/python/diskcache_rs/pickle_cache.py +0 -0
  57. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/python/diskcache_rs/recipes.py +0 -0
  58. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/python/diskcache_rs/rust_pickle.py +0 -0
  59. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/release-please-config.json +0 -0
  60. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/renovate.json +0 -0
  61. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/scripts/generate_stubs.py +0 -0
  62. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/scripts/sync_version.py +0 -0
  63. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/scripts/test-docker-network.sh +0 -0
  64. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/src/cache.rs +0 -0
  65. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/src/error.rs +0 -0
  66. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/src/lib.rs +0 -0
  67. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/src/memory_cache.rs +0 -0
  68. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/src/migration.rs +0 -0
  69. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/src/pickle_cache.rs +0 -0
  70. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/src/serialization.rs +0 -0
  71. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/src/storage/tests.rs +0 -0
  72. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/src/storage.rs +0 -0
  73. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/src/utils.rs +0 -0
  74. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/__init__.py +0 -0
  75. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/benchmark_official.py +0 -0
  76. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_api_compatibility.py +0 -0
  77. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_basic_operations.py +0 -0
  78. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_batch_operations.py +0 -0
  79. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_compatibility.py +0 -0
  80. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_complete_api_gaps.py +0 -0
  81. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_cross_platform_network.py +0 -0
  82. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_diskcache_rs_persistence_suite.py +0 -0
  83. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_docker_network.py +0 -0
  84. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_fast_cache.py +0 -0
  85. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_full_api_compatibility.py +0 -0
  86. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_issue_125_djangocache_multiprocess.py +0 -0
  87. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_issue_17_configurable_threshold.py +0 -0
  88. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_issue_345_nfs_safe_sqlite.py +0 -0
  89. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_issue_73_deterministic_hashing.py +0 -0
  90. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_issue_78_expire_method.py +0 -0
  91. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_network_filesystem.py +0 -0
  92. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_pickle_cache.py +0 -0
  93. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_recipes_and_constants.py +0 -0
  94. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_rust_pickle_performance.py +0 -0
  95. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/tests/test_version_and_disk_threshold.py +0 -0
  96. {diskcache_rs-0.4.10 → diskcache_rs-0.4.13}/uv.lock +0 -0
@@ -18,7 +18,7 @@ runs:
18
18
  using: 'composite'
19
19
  steps:
20
20
  - name: Install uv
21
- uses: astral-sh/setup-uv@v8.1.0
21
+ uses: astral-sh/setup-uv@v8.3.2
22
22
  with:
23
23
  python-version: ${{ inputs.python-version }}
24
24
 
@@ -33,7 +33,7 @@ jobs:
33
33
  uses: dtolnay/rust-toolchain@stable
34
34
 
35
35
  - name: Install uv
36
- uses: astral-sh/setup-uv@v8.1.0
36
+ uses: astral-sh/setup-uv@v8.3.2
37
37
 
38
38
  - name: Install dependencies
39
39
  run: |
@@ -17,7 +17,7 @@ jobs:
17
17
  runs-on: ubuntu-latest
18
18
  strategy:
19
19
  matrix:
20
- target: [x86_64, i686]
20
+ target: [x86_64]
21
21
  steps:
22
22
  - uses: actions/checkout@v6
23
23
  - uses: actions/setup-python@v6
@@ -20,7 +20,7 @@ jobs:
20
20
  runs-on: ubuntu-latest
21
21
  strategy:
22
22
  matrix:
23
- target: [x86_64, i686]
23
+ target: [x86_64]
24
24
  steps:
25
25
  - uses: actions/checkout@v6
26
26
  - uses: actions/setup-python@v6
@@ -98,7 +98,6 @@ jobs:
98
98
  matrix:
99
99
  target:
100
100
  - x86_64-unknown-linux-musl
101
- - i686-unknown-linux-musl
102
101
  steps:
103
102
  - uses: actions/checkout@v6
104
103
  - uses: actions/setup-python@v6
@@ -11,6 +11,11 @@ on:
11
11
  - 'v*'
12
12
  - 'diskcache_rs-v*' # Support release-please tag format
13
13
  workflow_dispatch:
14
+ inputs:
15
+ tag_name:
16
+ description: Existing release tag to rebuild and republish
17
+ required: false
18
+ type: string
14
19
 
15
20
  permissions:
16
21
  contents: write # Required for creating releases and uploading artifacts
@@ -37,7 +42,7 @@ jobs:
37
42
  # Call the build workflow to build standard wheels (only if release was created)
38
43
  build:
39
44
  needs: release-please
40
- if: ${{ needs.release-please.outputs.release_created }}
45
+ if: ${{ needs.release-please.outputs.release_created || (github.event_name == 'workflow_dispatch' && inputs.tag_name != '') }}
41
46
  uses: ./.github/workflows/build.yml
42
47
  permissions:
43
48
  contents: read
@@ -47,7 +52,7 @@ jobs:
47
52
  # Call the ABI3 build workflow to build universal wheels (only if release was created)
48
53
  build-abi3:
49
54
  needs: release-please
50
- if: ${{ needs.release-please.outputs.release_created }}
55
+ if: ${{ needs.release-please.outputs.release_created || (github.event_name == 'workflow_dispatch' && inputs.tag_name != '') }}
51
56
  uses: ./.github/workflows/build-abi3.yml
52
57
  permissions:
53
58
  contents: read
@@ -57,7 +62,7 @@ jobs:
57
62
  # Call the CI workflow to run tests (only if release was created)
58
63
  test:
59
64
  needs: release-please
60
- if: ${{ needs.release-please.outputs.release_created }}
65
+ if: ${{ needs.release-please.outputs.release_created || (github.event_name == 'workflow_dispatch' && inputs.tag_name != '') }}
61
66
  uses: ./.github/workflows/ci.yml
62
67
  permissions:
63
68
  contents: read
@@ -108,7 +113,7 @@ jobs:
108
113
  name: Create GitHub Release
109
114
  runs-on: ubuntu-latest
110
115
  needs: [release-please, pypi-publish]
111
- if: ${{ needs.release-please.outputs.release_created }}
116
+ if: ${{ needs.release-please.outputs.release_created || (github.event_name == 'workflow_dispatch' && inputs.tag_name != '') }}
112
117
  permissions:
113
118
  contents: write # Required for creating releases
114
119
  actions: read # Required for downloading artifacts
@@ -153,8 +158,8 @@ jobs:
153
158
  with:
154
159
  artifacts: "release-artifacts/*"
155
160
  token: ${{ secrets.GITHUB_TOKEN }}
156
- tag: ${{ needs.release-please.outputs.tag_name }}
157
- name: ${{ needs.release-please.outputs.tag_name }}
161
+ tag: ${{ inputs.tag_name || needs.release-please.outputs.tag_name }}
162
+ name: ${{ inputs.tag_name || needs.release-please.outputs.tag_name }}
158
163
  body: |
159
164
  Comparing Changes: ${{ steps.changelog.outputs.compareurl }}
160
165
 
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.4.13"
3
+ }
@@ -0,0 +1,90 @@
1
+ # AGENTS.md — diskcache_rs
2
+
3
+ > High-performance disk cache implemented in Rust with PyO3 Python bindings,
4
+ > built and shipped with maturin as the `diskcache_rs` PyPI package — a
5
+ > drop-in, faster alternative to the pure-Python `diskcache`.
6
+ > Navigation map for AI agents, not a reference manual. Follow the links; do
7
+ > not read everything up front.
8
+
9
+ ## Build & test
10
+
11
+ This repo has a justfile — use it. Run `just --list` for the live recipe list.
12
+
13
+ ```bash
14
+ vx just dev # install + build + stubs: full dev environment setup
15
+ vx just build # uvx maturin develop (debug extension module)
16
+ vx just build-release # uvx maturin develop --release
17
+ vx just test # uv run python -m pytest tests/ -v
18
+ vx just test-cov # pytest with HTML coverage for diskcache_rs
19
+ vx just check # format + lint + test (the local CI equivalent)
20
+ vx just lint # cargo clippy -- -D warnings, then uv run ruff check .
21
+ vx just format # cargo fmt --all, then uv run ruff format .
22
+ vx just fix # clippy --fix + ruff check --fix
23
+ ```
24
+
25
+ Release-oriented recipes:
26
+
27
+ ```bash
28
+ vx just release # uvx maturin build --release
29
+ vx just release-abi3 # uvx maturin build --release --features abi3 (Python 3.8+)
30
+ vx just publish # release, then uvx maturin publish (needs PyPI auth)
31
+ vx just sync-version # scripts/sync_version.py: Cargo.toml <-> pyproject.toml
32
+ vx just stubs # regenerate .pyi stubs with pyo3-stubgen
33
+ vx just verify-stubs # confirm .pyi files land inside the built wheel
34
+ vx just bench # pytest -k benchmark
35
+ vx just bench-pickle # benchmarks/pickle_bridge_comparison.py
36
+ vx just audit # cargo audit
37
+ ```
38
+
39
+ Requires Rust 1.87+, Python 3.8+, and `uv` / `maturin`.
40
+
41
+ ## Repo layout
42
+
43
+ | Path | Role |
44
+ |---|---|
45
+ | `src/cache.rs` | Core cache implementation and the PyO3 class surface |
46
+ | `src/storage.rs`, `src/storage/optimized_backend.rs` | SQLite-backed persistent storage (`rusqlite`, bundled) |
47
+ | `src/memory_cache.rs`, `src/eviction.rs` | In-memory tier and eviction policy |
48
+ | `src/serialization.rs` | Serializers: `serde_json`, `bincode`, `rmp-serde`, `postcard`, `lz4_flex` |
49
+ | `src/pickle_cache.rs` | Pickle-compatible values via the Rust pickle bridge |
50
+ | `src/migration.rs` | Import/migration path from the pure-Python `diskcache` |
51
+ | `src/error.rs`, `src/utils.rs` | Error types and helpers (`blake3`, `dashmap`, `parking_lot`) |
52
+ | `python/diskcache_rs/` | Python package wrapper: `cache.py`, `core.py`, `disk.py`, `fast_cache.py`, `pickle_cache.py`, `djangocache.py`, `recipes.py`, `constants.py`, plus `.pyi` stubs |
53
+ | `tests/` | Pytest suite — API-compatibility, persistence, network filesystem, NFS-safe SQLite, Django cache, performance |
54
+ | `benchmarks/` | Standalone performance and profiling scripts (not part of `just test`) |
55
+ | `examples/` | `basic_usage.py`, `special_chars_keys_example.py` |
56
+ | `scripts/` | `sync_version.py`, `generate_stubs.py`, `test-docker-network.sh` |
57
+ | `API_COMPATIBILITY.md` | Behavioural delta against upstream `diskcache` — read before changing public API |
58
+ | `Dockerfile.test`, `docker-compose.test.yml` | Containerised network-filesystem tests |
59
+
60
+ ## Release
61
+
62
+ - release-please drives versioning from Conventional Commits on `main`
63
+ (`release-please-config.json`). `.release-please-manifest.json` is the single
64
+ source of version truth.
65
+ - `feat:` → minor, `fix:` → patch, `chore:`/`docs:`/`ci:` → **no release**.
66
+ - Use `chore:`/`docs:` for config and doc work so release-please does not cut a
67
+ valueless version.
68
+ - Merging the release PR triggers `.github/workflows/release.yml`, which calls
69
+ `build.yml` and `build-abi3.yml` to produce both wheel flavours, then
70
+ publishes to PyPI and creates the GitHub release.
71
+ - `Cargo.toml` and `pyproject.toml` must carry the same version —
72
+ `just sync-version` is the supported way to reconcile them.
73
+
74
+ ## Do / Don't
75
+
76
+ - **Do** keep the two wheels working: any new PyO3 surface must build under
77
+ both the default and the `abi3` (`abi3-py38`) feature.
78
+ - **Do** regenerate stubs (`just stubs`) and confirm them in the wheel
79
+ (`just verify-stubs`) after changing the Rust API.
80
+ - **Do** check `API_COMPATIBILITY.md` before changing anything the pure-Python
81
+ `diskcache` also exposes.
82
+ - **Don't** edit `python/diskcache_rs/*.pyi` by hand — they are generated.
83
+ - **Don't** hardcode an exact version in tests (`assert __version__ == "X.Y.Z"`)
84
+ — release-please bumps will break it. Use `>=` or read package metadata.
85
+ `tests/test_version_and_disk_threshold.py` already depends on this.
86
+ - **Don't** add `CLAUDE.md` / `GEMINI.md` / `CURSOR.md` / `ANTHROPIC.md` /
87
+ `OPENAI.md` / `COPILOT.md` / `CODEBUDDY.md` / `.cursorrules` / `.clinerules` /
88
+ `.windsurfrules` at the root. This file is the only agent contract file.
89
+ - **Don't** commit build artifacts to the repo root (`target/`, `dist/`,
90
+ `htmlcov/`, `coverage.json`, `*.so`, `*.pyd`).
@@ -4,6 +4,44 @@
4
4
 
5
5
  - sync Cargo.toml version with .cz.toml and update CHANGELOG for v0.4.0
6
6
 
7
+ ## [0.4.13](https://github.com/loonghao/diskcache_rs/compare/diskcache_rs-v0.4.12...diskcache_rs-v0.4.13) (2026-11-27)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * repair v0.4.12 release pipeline ([8e05833](https://github.com/loonghao/diskcache_rs/commit/8e058333a20659e067a4b1f127e50334c4064fd0))
13
+
14
+ ## [0.4.12](https://github.com/loonghao/diskcache_rs/compare/diskcache_rs-v0.4.11...diskcache_rs-v0.4.12) (2026-10-14)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * clear frequency-0 bucket in LfuEviction::on_access ([#149](https://github.com/loonghao/diskcache_rs/issues/149)) ([9cd0c23](https://github.com/loonghao/diskcache_rs/commit/9cd0c236543970a707912114bdbd2a8c743db0b0))
20
+ * **deps:** update rust crate pyo3 to 0.29 ([2e355aa](https://github.com/loonghao/diskcache_rs/commit/2e355aabf3b78b83db404335d75babef4e56e689))
21
+ * **deps:** update rust crate rusqlite to 0.40 ([44b3a65](https://github.com/loonghao/diskcache_rs/commit/44b3a6531a41266101abef4eda4d77671339fa42))
22
+
23
+
24
+ ### Documentation
25
+
26
+ * add AGENTS.md agent contract ([#146](https://github.com/loonghao/diskcache_rs/issues/146)) ([d6d10bb](https://github.com/loonghao/diskcache_rs/commit/d6d10bb39707f599c722b3302eec7b9da35b905e))
27
+
28
+ ## [0.4.11](https://github.com/loonghao/diskcache_rs/compare/diskcache_rs-v0.4.10...diskcache_rs-v0.4.11) (2026-05-12)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * **deps:** update rust crate lru to 0.18 ([0c0138f](https://github.com/loonghao/diskcache_rs/commit/0c0138f65f4b6d16cd664db6720f927211e10a3f))
34
+ * optimize sqlite inline cache index ([5a885ba](https://github.com/loonghao/diskcache_rs/commit/5a885bafa8c5b0a7653773a94f32232dc0dfd3af))
35
+ * strengthen sqlite multiprocess consistency ([e121661](https://github.com/loonghao/diskcache_rs/commit/e121661cc1e6d8d54f7670bd471c3da4e776fb47))
36
+ * support django cache and multiprocess opens ([044f244](https://github.com/loonghao/diskcache_rs/commit/044f244b817d4db5ec3fd13cdfbac21f184ac032))
37
+
38
+
39
+ ### Performance Improvements
40
+
41
+ * avoid pickling bytes values ([b081349](https://github.com/loonghao/diskcache_rs/commit/b081349082265683b891a96dff23258849c273bc))
42
+ * keep medium values inline ([62ed5e7](https://github.com/loonghao/diskcache_rs/commit/62ed5e7f986b6d52887e00c61441ee1d01150235))
43
+ * restore sqlite hot-read path ([2da51ee](https://github.com/loonghao/diskcache_rs/commit/2da51ee478f631941a57c344805db40495f07386))
44
+
7
45
  ## [0.4.10](https://github.com/loonghao/diskcache_rs/compare/diskcache_rs-v0.4.9...diskcache_rs-v0.4.10) (2026-04-15)
8
46
 
9
47
 
@@ -19,15 +19,9 @@ dependencies = [
19
19
 
20
20
  [[package]]
21
21
  name = "anyhow"
22
- version = "1.0.102"
22
+ version = "1.0.105"
23
23
  source = "registry+https://github.com/rust-lang/crates.io-index"
24
- checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
25
-
26
- [[package]]
27
- name = "arrayref"
28
- version = "0.3.9"
29
- source = "registry+https://github.com/rust-lang/crates.io-index"
30
- checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb"
24
+ checksum = "2cb931c189b85683d69a5cfad41d4d418671e1ac413dd209f3f2fc31e3cfd902"
31
25
 
32
26
  [[package]]
33
27
  name = "arrayvec"
@@ -78,11 +72,10 @@ checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
78
72
 
79
73
  [[package]]
80
74
  name = "blake3"
81
- version = "1.8.4"
75
+ version = "1.8.8"
82
76
  source = "registry+https://github.com/rust-lang/crates.io-index"
83
- checksum = "4d2d5991425dfd0785aed03aedcf0b321d61975c9b5b3689c774a2610ae0b51e"
77
+ checksum = "64c0e36294adc8db531500e3f2b8ec75c4af9177271e9c6d33f93609d56e57cd"
84
78
  dependencies = [
85
- "arrayref",
86
79
  "arrayvec",
87
80
  "cc",
88
81
  "cfg-if",
@@ -104,9 +97,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
104
97
 
105
98
  [[package]]
106
99
  name = "bytes"
107
- version = "1.11.1"
100
+ version = "1.12.2"
108
101
  source = "registry+https://github.com/rust-lang/crates.io-index"
109
- checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33"
102
+ checksum = "776dfebd015e2d8732c684a2c71003674ccb49457b539b9e82151ba38e96dd7c"
110
103
 
111
104
  [[package]]
112
105
  name = "cc"
@@ -126,9 +119,9 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
126
119
 
127
120
  [[package]]
128
121
  name = "chrono"
129
- version = "0.4.44"
122
+ version = "0.4.45"
130
123
  source = "registry+https://github.com/rust-lang/crates.io-index"
131
- checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0"
124
+ checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327"
132
125
  dependencies = [
133
126
  "iana-time-zone",
134
127
  "js-sys",
@@ -149,9 +142,12 @@ dependencies = [
149
142
 
150
143
  [[package]]
151
144
  name = "constant_time_eq"
152
- version = "0.4.2"
145
+ version = "0.6.2"
153
146
  source = "registry+https://github.com/rust-lang/crates.io-index"
154
- checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b"
147
+ checksum = "144e7f1de087984240b7816d47f698b414979faa6f40839c5b86d6bd47db57b7"
148
+ dependencies = [
149
+ "rustversion",
150
+ ]
155
151
 
156
152
  [[package]]
157
153
  name = "core-foundation-sys"
@@ -176,9 +172,9 @@ checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b"
176
172
 
177
173
  [[package]]
178
174
  name = "crossbeam"
179
- version = "0.8.4"
175
+ version = "0.8.5"
180
176
  source = "registry+https://github.com/rust-lang/crates.io-index"
181
- checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8"
177
+ checksum = "e71406cd8807725f7ac2f999a4cdd32e98f829fdf65f528343cebf945e41df1e"
182
178
  dependencies = [
183
179
  "crossbeam-channel",
184
180
  "crossbeam-deque",
@@ -232,9 +228,9 @@ checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
232
228
 
233
229
  [[package]]
234
230
  name = "dashmap"
235
- version = "6.1.0"
231
+ version = "6.2.1"
236
232
  source = "registry+https://github.com/rust-lang/crates.io-index"
237
- checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf"
233
+ checksum = "e6361d5c062261c78a176addb82d4c821ae42bed6089de0e12603cd25de2059c"
238
234
  dependencies = [
239
235
  "cfg-if",
240
236
  "crossbeam-utils",
@@ -246,7 +242,7 @@ dependencies = [
246
242
 
247
243
  [[package]]
248
244
  name = "diskcache_rs"
249
- version = "0.4.10"
245
+ version = "0.4.13"
250
246
  dependencies = [
251
247
  "anyhow",
252
248
  "bincode",
@@ -508,15 +504,15 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
508
504
 
509
505
  [[package]]
510
506
  name = "libc"
511
- version = "0.2.185"
507
+ version = "0.2.186"
512
508
  source = "registry+https://github.com/rust-lang/crates.io-index"
513
- checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f"
509
+ checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
514
510
 
515
511
  [[package]]
516
512
  name = "libsqlite3-sys"
517
- version = "0.37.0"
513
+ version = "0.38.0"
518
514
  source = "registry+https://github.com/rust-lang/crates.io-index"
519
- checksum = "b1f111c8c41e7c61a49cd34e44c7619462967221a6443b0ec299e0ac30cfb9b1"
515
+ checksum = "a76001fb4daed01e5f2b518aac0b4dc592e7c734da63dbffcf0c64fa612a8d0c"
520
516
  dependencies = [
521
517
  "cc",
522
518
  "pkg-config",
@@ -607,9 +603,9 @@ dependencies = [
607
603
 
608
604
  [[package]]
609
605
  name = "once_cell"
610
- version = "1.21.3"
606
+ version = "1.21.4"
611
607
  source = "registry+https://github.com/rust-lang/crates.io-index"
612
- checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
608
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
613
609
 
614
610
  [[package]]
615
611
  name = "parking_lot"
@@ -692,9 +688,9 @@ dependencies = [
692
688
 
693
689
  [[package]]
694
690
  name = "pyo3"
695
- version = "0.28.3"
691
+ version = "0.29.3"
696
692
  source = "registry+https://github.com/rust-lang/crates.io-index"
697
- checksum = "91fd8e38a3b50ed1167fb981cd6fd60147e091784c427b8f7183a7ee32c31c12"
693
+ checksum = "700d18fa267b73b9b521fd7e13580e2f446916f176cacee1ab63fcc8191f1655"
698
694
  dependencies = [
699
695
  "libc",
700
696
  "once_cell",
@@ -706,18 +702,18 @@ dependencies = [
706
702
 
707
703
  [[package]]
708
704
  name = "pyo3-build-config"
709
- version = "0.28.3"
705
+ version = "0.29.3"
710
706
  source = "registry+https://github.com/rust-lang/crates.io-index"
711
- checksum = "e368e7ddfdeb98c9bca7f8383be1648fd84ab466bf2bc015e94008db6d35611e"
707
+ checksum = "7b3fc0c4d08f6bb10e71fe39dfb9e2f59c6eb6854e22ec8092f50c69a4499adb"
712
708
  dependencies = [
713
709
  "target-lexicon",
714
710
  ]
715
711
 
716
712
  [[package]]
717
713
  name = "pyo3-ffi"
718
- version = "0.28.3"
714
+ version = "0.29.3"
719
715
  source = "registry+https://github.com/rust-lang/crates.io-index"
720
- checksum = "7f29e10af80b1f7ccaf7f69eace800a03ecd13e883acfacc1e5d0988605f651e"
716
+ checksum = "dfc0b8e19df29aad7086cf977bb0c2a2f143e30567eb113e9cf72b62ca698330"
721
717
  dependencies = [
722
718
  "libc",
723
719
  "pyo3-build-config",
@@ -725,9 +721,9 @@ dependencies = [
725
721
 
726
722
  [[package]]
727
723
  name = "pyo3-macros"
728
- version = "0.28.3"
724
+ version = "0.29.3"
729
725
  source = "registry+https://github.com/rust-lang/crates.io-index"
730
- checksum = "df6e520eff47c45997d2fc7dd8214b25dd1310918bbb2642156ef66a67f29813"
726
+ checksum = "6100e8a4b5eba53afaa5ed078364851a0b2499c553a44c31026b929049b49dc6"
731
727
  dependencies = [
732
728
  "proc-macro2",
733
729
  "pyo3-macros-backend",
@@ -737,13 +733,12 @@ dependencies = [
737
733
 
738
734
  [[package]]
739
735
  name = "pyo3-macros-backend"
740
- version = "0.28.3"
736
+ version = "0.29.3"
741
737
  source = "registry+https://github.com/rust-lang/crates.io-index"
742
- checksum = "c4cdc218d835738f81c2338f822078af45b4afdf8b2e33cbb5916f108b813acb"
738
+ checksum = "6143877a16e82b5a727b7127ff4cd86858a24a28d745d72f43e6f227c7b1bdb3"
743
739
  dependencies = [
744
740
  "heck",
745
741
  "proc-macro2",
746
- "pyo3-build-config",
747
742
  "quote",
748
743
  "syn",
749
744
  ]
@@ -804,9 +799,9 @@ dependencies = [
804
799
 
805
800
  [[package]]
806
801
  name = "rusqlite"
807
- version = "0.39.0"
802
+ version = "0.40.0"
808
803
  source = "registry+https://github.com/rust-lang/crates.io-index"
809
- checksum = "a0d2b0146dd9661bf67bb107c0bb2a55064d556eeb3fc314151b957f313bcd4e"
804
+ checksum = "1b3492ea85308705c3a5cc24fb9b9cf77273d30590349070db42991202b214c4"
810
805
  dependencies = [
811
806
  "bitflags",
812
807
  "chrono",
@@ -903,9 +898,9 @@ dependencies = [
903
898
 
904
899
  [[package]]
905
900
  name = "serde_json"
906
- version = "1.0.149"
901
+ version = "1.0.154"
907
902
  source = "registry+https://github.com/rust-lang/crates.io-index"
908
- checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
903
+ checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
909
904
  dependencies = [
910
905
  "itoa",
911
906
  "memchr",
@@ -1061,9 +1056,9 @@ checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae"
1061
1056
 
1062
1057
  [[package]]
1063
1058
  name = "uuid"
1064
- version = "1.23.1"
1059
+ version = "1.23.3"
1065
1060
  source = "registry+https://github.com/rust-lang/crates.io-index"
1066
- checksum = "ddd74a9687298c6858e9b88ec8935ec45d22e8fd5e6394fa1bd4e99a87789c76"
1061
+ checksum = "144d6b123cef80b301b8f72a9e2ca4370ddec21950d0a103dd22c437006d2db7"
1067
1062
  dependencies = [
1068
1063
  "getrandom",
1069
1064
  "js-sys",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "diskcache_rs"
3
- version = "0.4.10"
3
+ version = "0.4.13"
4
4
  edition = "2021"
5
5
  authors = ["longhao <hal.long@outlook.com>"]
6
6
  description = "A high-performance disk cache implementation in Rust with Python bindings"
@@ -28,7 +28,7 @@ panic = "abort"
28
28
  strip = "symbols"
29
29
 
30
30
  [dependencies]
31
- pyo3 = { version = "0.28", features = ["extension-module"] }
31
+ pyo3 = { version = "0.29.3", features = ["extension-module"] }
32
32
  serde = { version = "1.0", features = ["derive"] }
33
33
  serde_json = "1.0"
34
34
  bincode = "2.0"
@@ -36,7 +36,7 @@ rmp-serde = "1.3"
36
36
  # Keep only what we actually use
37
37
  postcard = { version = "1.1", features = ["alloc"] }
38
38
  # SQLite for diskcache-compatible storage
39
- rusqlite = { version = "0.39", features = ["bundled", "blob", "chrono"] }
39
+ rusqlite = { version = "0.40", features = ["bundled", "blob", "chrono"] }
40
40
 
41
41
  # tokio removed - using std::thread instead for simplicity
42
42
  parking_lot = "0.12"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: diskcache_rs
3
- Version: 0.4.10
3
+ Version: 0.4.13
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: Apache Software License
@@ -101,13 +101,15 @@ impl EvictionPolicy for LfuEviction {
101
101
  let old_freq = key_to_frequency.get(key).copied().unwrap_or(0);
102
102
  let new_freq = entry.access_count;
103
103
 
104
- // Remove from old frequency bucket
105
- if old_freq > 0 {
106
- if let Some(bucket) = frequency_order.get_mut(&old_freq) {
107
- bucket.retain(|k| k != key);
108
- if bucket.is_empty() {
109
- frequency_order.remove(&old_freq);
110
- }
104
+ // Remove from old frequency bucket. This must run unconditionally: a
105
+ // key inserted with access_count == 0 lives in bucket 0, so guarding on
106
+ // `old_freq > 0` would leave a stale copy behind and make
107
+ // `select_victims` return the same key twice. For a brand new key the
108
+ // lookup simply misses and this is a no-op.
109
+ if let Some(bucket) = frequency_order.get_mut(&old_freq) {
110
+ bucket.retain(|k| k != key);
111
+ if bucket.is_empty() {
112
+ frequency_order.remove(&old_freq);
111
113
  }
112
114
  }
113
115
 
@@ -142,7 +144,7 @@ impl EvictionPolicy for LfuEviction {
142
144
  let frequency_order = self.frequency_order.read();
143
145
  let mut victims = Vec::new();
144
146
 
145
- for (_, keys) in frequency_order.iter() {
147
+ for keys in frequency_order.values() {
146
148
  for key in keys {
147
149
  if victims.len() >= count {
148
150
  break;
@@ -438,3 +440,112 @@ impl EvictionPolicy for CombinedEviction {
438
440
  self.least_recently_stored.clear();
439
441
  }
440
442
  }
443
+
444
+ #[cfg(test)]
445
+ mod tests {
446
+ use super::*;
447
+
448
+ /// Build a cache entry carrying an explicit access count.
449
+ fn entry_with_access_count(key: &str, access_count: u64) -> CacheEntry {
450
+ let mut entry = CacheEntry::new_inline(key.to_string(), b"value".to_vec(), vec![], None);
451
+ entry.access_count = access_count;
452
+ entry
453
+ }
454
+
455
+ /// A key must never appear twice in `select_victims`, even after it is
456
+ /// promoted out of the frequency-0 bucket.
457
+ #[test]
458
+ fn select_victims_has_no_duplicate_keys_after_frequency_zero_promotion() {
459
+ let policy = LfuEviction::new();
460
+
461
+ // Insert lands the key in the frequency-0 bucket (access_count == 0).
462
+ policy.on_insert("a", &entry_with_access_count("a", 0));
463
+ // A later access promotes it out of bucket 0 into bucket 1.
464
+ policy.on_access("a", &entry_with_access_count("a", 1));
465
+
466
+ let victims = policy.select_victims(10);
467
+
468
+ let unique: std::collections::HashSet<_> = victims.iter().collect();
469
+ assert_eq!(
470
+ unique.len(),
471
+ victims.len(),
472
+ "same key selected more than once: {victims:?}"
473
+ );
474
+ assert_eq!(victims, vec!["a".to_string()]);
475
+ }
476
+
477
+ /// Victims are ordered by ascending frequency, with the least frequently
478
+ /// used keys evicted first.
479
+ #[test]
480
+ fn select_victims_orders_by_ascending_frequency() {
481
+ let policy = LfuEviction::new();
482
+
483
+ policy.on_insert("low", &entry_with_access_count("low", 0));
484
+ policy.on_insert("mid", &entry_with_access_count("mid", 3));
485
+ policy.on_insert("high", &entry_with_access_count("high", 7));
486
+
487
+ let victims = policy.select_victims(10);
488
+
489
+ assert_eq!(
490
+ victims,
491
+ vec!["low".to_string(), "mid".to_string(), "high".to_string()],
492
+ "expected victims ordered by ascending frequency"
493
+ );
494
+ }
495
+
496
+ /// Promotion must move a key between buckets, not copy it, so the number of
497
+ /// selectable victims still matches the number of tracked keys.
498
+ #[test]
499
+ fn select_victims_count_after_promotion_matches_tracked_keys() {
500
+ let policy = LfuEviction::new();
501
+
502
+ for key in ["a", "b", "c"] {
503
+ policy.on_insert(key, &entry_with_access_count(key, 0));
504
+ }
505
+ // Promote "a" and "b" out of the frequency-0 bucket.
506
+ policy.on_access("a", &entry_with_access_count("a", 1));
507
+ policy.on_access("b", &entry_with_access_count("b", 2));
508
+
509
+ // Three keys are tracked, so three distinct victims must be available.
510
+ let victims = policy.select_victims(3);
511
+ assert_eq!(
512
+ victims.len(),
513
+ 3,
514
+ "expected 3 distinct victims, got {victims:?}"
515
+ );
516
+
517
+ let unique: std::collections::HashSet<_> = victims.iter().collect();
518
+ assert_eq!(unique.len(), 3, "duplicate victims returned: {victims:?}");
519
+ }
520
+
521
+ /// `select_victims` never returns more keys than requested.
522
+ #[test]
523
+ fn select_victims_respects_requested_count() {
524
+ let policy = LfuEviction::new();
525
+
526
+ for key in ["a", "b", "c", "d"] {
527
+ policy.on_insert(key, &entry_with_access_count(key, 0));
528
+ }
529
+
530
+ assert_eq!(policy.select_victims(0).len(), 0);
531
+ assert_eq!(policy.select_victims(2).len(), 2);
532
+ assert_eq!(policy.select_victims(10).len(), 4);
533
+ }
534
+
535
+ /// A repeated access at an unchanged frequency must not duplicate the key.
536
+ #[test]
537
+ fn repeated_access_at_same_frequency_does_not_duplicate_key() {
538
+ let policy = LfuEviction::new();
539
+
540
+ policy.on_insert("a", &entry_with_access_count("a", 2));
541
+ policy.on_access("a", &entry_with_access_count("a", 2));
542
+ policy.on_access("a", &entry_with_access_count("a", 2));
543
+
544
+ let victims = policy.select_victims(10);
545
+ assert_eq!(
546
+ victims,
547
+ vec!["a".to_string()],
548
+ "repeated access must not duplicate the key in its bucket"
549
+ );
550
+ }
551
+ }
@@ -12,7 +12,7 @@ use std::collections::VecDeque;
12
12
  use std::fs::{File, OpenOptions};
13
13
  use std::io::{BufWriter, Write};
14
14
  use std::path::{Path, PathBuf};
15
- use std::sync::atomic::{AtomicU64, Ordering};
15
+ use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
16
16
  use std::sync::mpsc;
17
17
  use std::sync::Arc;
18
18
  use std::time::Duration;
@@ -48,6 +48,9 @@ pub struct OptimizedStorage {
48
48
 
49
49
  // Statistics
50
50
  stats: Arc<StorageStats>,
51
+
52
+ // Prevent close and drop from persisting the index twice.
53
+ closed: AtomicBool,
51
54
  }
52
55
 
53
56
  #[derive(Clone)]
@@ -349,6 +352,7 @@ impl OptimizedStorage {
349
352
  write_batcher,
350
353
  config,
351
354
  stats: Arc::new(StorageStats::default()),
355
+ closed: AtomicBool::new(false),
352
356
  };
353
357
 
354
358
  // Load existing index from SQLite
@@ -484,11 +488,33 @@ impl OptimizedStorage {
484
488
 
485
489
  /// Close background resources and flush in-memory data.
486
490
  pub fn close_db(&self) {
491
+ if self.closed.swap(true, Ordering::AcqRel) {
492
+ return;
493
+ }
494
+
487
495
  self.write_batcher.shutdown();
488
496
 
489
497
  if let Err(e) = self.flush_memory_caches() {
490
498
  tracing::error!("Failed to flush memory caches during close: {}", e);
491
499
  }
500
+
501
+ if let Err(e) = self.persist_index() {
502
+ tracing::error!("Failed to persist SQLite index during close: {}", e);
503
+ }
504
+
505
+ // rusqlite keeps the SQLite file handle in the Connection value. Replace
506
+ // it with an in-memory connection so the original database is dropped
507
+ // while the Python cache is being closed, including on Windows.
508
+ match Connection::open_in_memory() {
509
+ Ok(in_memory_connection) => {
510
+ let mut connection = self.index_db.lock();
511
+ let file_connection = std::mem::replace(&mut *connection, in_memory_connection);
512
+ drop(file_connection);
513
+ }
514
+ Err(e) => {
515
+ tracing::error!("Failed to release SQLite index during close: {}", e);
516
+ }
517
+ }
492
518
  }
493
519
 
494
520
  /// Flush in-flight file writes. Cache entries are already persisted when set.
@@ -1141,9 +1167,11 @@ impl OptimizedStorage {
1141
1167
 
1142
1168
  impl Drop for OptimizedStorage {
1143
1169
  fn drop(&mut self) {
1144
- self.write_batcher.shutdown();
1145
- // Ensure index is persisted when storage is dropped
1146
- let _ = self.persist_index();
1170
+ if !self.closed.load(Ordering::Acquire) {
1171
+ self.write_batcher.shutdown();
1172
+ // Ensure index is persisted when storage is dropped
1173
+ let _ = self.persist_index();
1174
+ }
1147
1175
  }
1148
1176
  }
1149
1177
 
@@ -67,11 +67,13 @@ def cache(temp_cache_dir):
67
67
  """Create a cache instance for testing"""
68
68
  from diskcache_rs import Cache
69
69
 
70
- return Cache(
70
+ cache = Cache(
71
71
  temp_cache_dir,
72
72
  max_size=1024 * 1024, # 1MB
73
73
  max_entries=1000,
74
74
  )
75
+ yield cache
76
+ cache.close()
75
77
 
76
78
 
77
79
  @pytest.fixture
@@ -79,11 +81,13 @@ def large_cache(temp_cache_dir):
79
81
  """Create a larger cache instance for performance testing"""
80
82
  from diskcache_rs import Cache
81
83
 
82
- return Cache(
84
+ cache = Cache(
83
85
  temp_cache_dir,
84
86
  max_size=100 * 1024 * 1024, # 100MB
85
87
  max_entries=10000,
86
88
  )
89
+ yield cache
90
+ cache.close()
87
91
 
88
92
 
89
93
  @pytest.fixture
@@ -105,11 +109,13 @@ def cloud_cache(cloud_cache_dir):
105
109
  """Create a cache instance on cloud drive"""
106
110
  from diskcache_rs import Cache
107
111
 
108
- return Cache(
112
+ cache = Cache(
109
113
  cloud_cache_dir,
110
114
  max_size=10 * 1024 * 1024, # 10MB
111
115
  max_entries=1000,
112
116
  )
117
+ yield cache
118
+ cache.close()
113
119
 
114
120
 
115
121
  @pytest.fixture
@@ -23,7 +23,9 @@ class TestCIBenchmarks:
23
23
  def cache(self, temp_cache_dir):
24
24
  """Create a cache instance"""
25
25
  cache_dir = os.path.join(temp_cache_dir, "test_cache")
26
- return Cache(cache_dir)
26
+ cache = Cache(cache_dir)
27
+ yield cache
28
+ cache.close()
27
29
 
28
30
  def test_benchmark_basic_operations(self, benchmark, cache):
29
31
  """Basic benchmark test for CI"""
@@ -266,7 +266,9 @@ class TestOfficialBenchmarks:
266
266
  def rust_cache(self, temp_cache_dir):
267
267
  """Create a Rust cache instance"""
268
268
  cache_dir = os.path.join(temp_cache_dir, "rust_cache")
269
- return RustCache(cache_dir)
269
+ cache = RustCache(cache_dir)
270
+ yield cache
271
+ cache.close()
270
272
 
271
273
  @pytest.fixture
272
274
  def python_cache(self, temp_cache_dir):
@@ -373,7 +375,9 @@ class TestBenchmarks:
373
375
  def rust_cache(self, temp_cache_dir):
374
376
  """Create a Rust cache instance"""
375
377
  cache_dir = os.path.join(temp_cache_dir, "rust_cache")
376
- return RustCache(cache_dir)
378
+ cache = RustCache(cache_dir)
379
+ yield cache
380
+ cache.close()
377
381
 
378
382
  @pytest.fixture
379
383
  def python_cache(self, temp_cache_dir):
@@ -29,6 +29,7 @@ class TestSpecialCharKeys:
29
29
 
30
30
  assert result == value
31
31
  assert key in cache
32
+ cache.close()
32
33
 
33
34
  def test_key_with_slash(self):
34
35
  """Test keys containing forward slash"""
@@ -44,6 +45,7 @@ class TestSpecialCharKeys:
44
45
 
45
46
  assert result == value
46
47
  assert key in cache
48
+ cache.close()
47
49
 
48
50
  def test_key_with_backslash(self):
49
51
  """Test keys containing backslash"""
@@ -59,6 +61,7 @@ class TestSpecialCharKeys:
59
61
 
60
62
  assert result == value
61
63
  assert key in cache
64
+ cache.close()
62
65
 
63
66
  def test_key_with_dot(self):
64
67
  """Test keys containing dot character"""
@@ -74,6 +77,7 @@ class TestSpecialCharKeys:
74
77
 
75
78
  assert result == value
76
79
  assert key in cache
80
+ cache.close()
77
81
 
78
82
  def test_key_with_multiple_special_chars(self):
79
83
  """Test keys with multiple special characters"""
@@ -98,6 +102,7 @@ class TestSpecialCharKeys:
98
102
  result = cache.get(key)
99
103
  assert result == value, f"Failed for key: {key}"
100
104
  assert key in cache
105
+ cache.close()
101
106
 
102
107
  def test_url_as_key(self):
103
108
  """Test using URLs as cache keys"""
@@ -117,6 +122,7 @@ class TestSpecialCharKeys:
117
122
 
118
123
  assert result == response_data
119
124
  assert url in cache
125
+ cache.close()
120
126
 
121
127
 
122
128
  class TestAutoDeserialization:
@@ -133,6 +139,7 @@ class TestAutoDeserialization:
133
139
  result = cache.get("test_key")
134
140
 
135
141
  assert result == value
142
+ cache.close()
136
143
 
137
144
  def test_json_deserialization(self):
138
145
  """Test automatic JSON deserialization"""
@@ -149,6 +156,7 @@ class TestAutoDeserialization:
149
156
  # Should auto-deserialize JSON
150
157
  result = cache.get("json_key")
151
158
  assert result == json_data
159
+ cache.close()
152
160
 
153
161
  def test_text_deserialization(self):
154
162
  """Test automatic text deserialization"""
@@ -165,6 +173,7 @@ class TestAutoDeserialization:
165
173
  # Should auto-deserialize to text
166
174
  result = cache.get("text_key")
167
175
  assert result == text
176
+ cache.close()
168
177
 
169
178
  def test_mixed_formats(self):
170
179
  """Test cache with mixed serialization formats"""
@@ -180,3 +189,4 @@ class TestAutoDeserialization:
180
189
  assert cache.get("pickle_key") == {"type": "pickle"}
181
190
  assert cache.get("json_key") == {"type": "json"}
182
191
  assert cache.get("text_key") == "plain text"
192
+ cache.close()
@@ -1,3 +0,0 @@
1
- {
2
- ".": "0.4.10"
3
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes