diskcache-rs 0.4.9__tar.gz → 0.4.10__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 (95) hide show
  1. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/.github/actions/setup-diskcache-rs/action.yml +1 -1
  2. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/.github/workflows/benchmark.yml +24 -26
  3. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/.github/workflows/build.yml +16 -2
  4. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/.github/workflows/release.yml +1 -1
  5. diskcache_rs-0.4.10/.release-please-manifest.json +3 -0
  6. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/CHANGELOG.md +7 -0
  7. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/Cargo.lock +35 -26
  8. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/Cargo.toml +3 -3
  9. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/PKG-INFO +1 -1
  10. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/benchmarks/performance_comparison.py +34 -0
  11. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/python/diskcache_rs/__init__.py +2 -5
  12. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/python/diskcache_rs/__init__.pyi +49 -17
  13. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/python/diskcache_rs/cache.py +19 -6
  14. diskcache_rs-0.4.10/python/diskcache_rs/djangocache.py +118 -0
  15. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/src/cache.rs +7 -9
  16. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/src/memory_cache.rs +1 -0
  17. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/src/migration.rs +1 -1
  18. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/src/storage/optimized_backend.rs +362 -503
  19. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_batch_operations.py +2 -2
  20. diskcache_rs-0.4.10/tests/test_issue_125_djangocache_multiprocess.py +194 -0
  21. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_issue_17_configurable_threshold.py +19 -18
  22. diskcache_rs-0.4.10/tests/test_issue_345_nfs_safe_sqlite.py +58 -0
  23. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_version_and_disk_threshold.py +18 -18
  24. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/uv.lock +44 -19
  25. diskcache_rs-0.4.9/.release-please-manifest.json +0 -3
  26. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  27. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  28. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/.github/actions/build-and-test/action.yml +0 -0
  29. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/.github/pull_request_template.md +0 -0
  30. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/.github/workflows/build-abi3.yml +0 -0
  31. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/.github/workflows/ci.yml +0 -0
  32. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/.gitignore +0 -0
  33. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/.pre-commit-config.yaml +0 -0
  34. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/API_COMPATIBILITY.md +0 -0
  35. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/Dockerfile.test +0 -0
  36. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/LICENSE +0 -0
  37. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/README.md +0 -0
  38. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/benchmarks/batch_write_comparison.py +0 -0
  39. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/benchmarks/comprehensive_performance_test.py +0 -0
  40. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/benchmarks/detailed_profiling.py +0 -0
  41. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/benchmarks/final_performance_comparison.py +0 -0
  42. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/benchmarks/high_performance_test.py +0 -0
  43. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/benchmarks/memory_usage_test.py +0 -0
  44. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/benchmarks/micro_benchmark.py +0 -0
  45. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/benchmarks/optimization_validation_test.py +0 -0
  46. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/benchmarks/pickle_bridge_comparison.py +0 -0
  47. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/benchmarks/precise_benchmark.py +0 -0
  48. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/benchmarks/set_performance_analysis.py +0 -0
  49. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/docker-compose.test.yml +0 -0
  50. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/examples/basic_usage.py +0 -0
  51. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/examples/special_chars_keys_example.py +0 -0
  52. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/justfile +0 -0
  53. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/pyproject.toml +0 -0
  54. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/python/diskcache_rs/_diskcache_rs.pyi +0 -0
  55. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/python/diskcache_rs/constants.py +0 -0
  56. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/python/diskcache_rs/core.py +0 -0
  57. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/python/diskcache_rs/disk.py +0 -0
  58. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/python/diskcache_rs/fast_cache.py +0 -0
  59. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/python/diskcache_rs/pickle_cache.py +0 -0
  60. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/python/diskcache_rs/recipes.py +0 -0
  61. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/python/diskcache_rs/rust_pickle.py +0 -0
  62. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/release-please-config.json +0 -0
  63. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/renovate.json +0 -0
  64. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/scripts/generate_stubs.py +0 -0
  65. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/scripts/sync_version.py +0 -0
  66. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/scripts/test-docker-network.sh +0 -0
  67. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/src/error.rs +0 -0
  68. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/src/eviction.rs +0 -0
  69. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/src/lib.rs +0 -0
  70. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/src/pickle_cache.rs +0 -0
  71. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/src/serialization.rs +0 -0
  72. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/src/storage/tests.rs +0 -0
  73. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/src/storage.rs +0 -0
  74. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/src/utils.rs +0 -0
  75. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/__init__.py +0 -0
  76. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/benchmark_official.py +0 -0
  77. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/conftest.py +0 -0
  78. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_api_compatibility.py +0 -0
  79. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_basic_operations.py +0 -0
  80. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_ci_benchmark.py +0 -0
  81. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_compatibility.py +0 -0
  82. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_complete_api_gaps.py +0 -0
  83. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_cross_platform_network.py +0 -0
  84. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_diskcache_rs_persistence_suite.py +0 -0
  85. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_docker_network.py +0 -0
  86. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_fast_cache.py +0 -0
  87. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_full_api_compatibility.py +0 -0
  88. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_issue_73_deterministic_hashing.py +0 -0
  89. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_issue_78_expire_method.py +0 -0
  90. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_network_filesystem.py +0 -0
  91. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_performance.py +0 -0
  92. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_pickle_cache.py +0 -0
  93. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_recipes_and_constants.py +0 -0
  94. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_rust_pickle_performance.py +0 -0
  95. {diskcache_rs-0.4.9 → diskcache_rs-0.4.10}/tests/test_special_chars_keys.py +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@v7
21
+ uses: astral-sh/setup-uv@v8.1.0
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@v7
36
+ uses: astral-sh/setup-uv@v8.1.0
37
37
 
38
38
  - name: Install dependencies
39
39
  run: |
@@ -63,7 +63,7 @@ jobs:
63
63
 
64
64
  - name: Comment PR with benchmark results
65
65
  if: github.event_name == 'pull_request'
66
- uses: actions/github-script@v8
66
+ uses: actions/github-script@v9
67
67
  with:
68
68
  script: |
69
69
  const fs = require('fs');
@@ -72,33 +72,31 @@ jobs:
72
72
  const results = JSON.parse(fs.readFileSync('benchmark_results.json', 'utf8'));
73
73
 
74
74
  let comment = '## 📊 Performance Benchmark Results\n\n';
75
- comment += '| Benchmark | python-diskcache | diskcache_rs | Winner |\n';
76
- comment += '|-----------|------------------|--------------|--------|\n';
75
+ comment += '| Benchmark | Metric | python-diskcache | diskcache_rs | Winner |\n';
76
+ comment += '|-----------|--------|------------------|--------------|--------|\n';
77
77
 
78
- for (const [name, result] of Object.entries(results)) {
79
- // Handle both old and new result formats
80
- let dcOps, rsOps;
81
- if (result.diskcache && result.diskcache_rs) {
82
- // New format with nested operations
83
- if (result.diskcache.get && result.diskcache_rs.get) {
84
- dcOps = result.diskcache.get.ops_per_sec;
85
- rsOps = result.diskcache_rs.get.ops_per_sec;
86
- } else {
87
- dcOps = result.diskcache.ops_per_sec || 0;
88
- rsOps = result.diskcache_rs.ops_per_sec || 0;
89
- }
90
- } else {
91
- continue; // Skip malformed results
92
- }
78
+ const addRow = (name, metric, dcOps, rsOps) => {
79
+ if (!dcOps || !rsOps) return;
80
+ const winner = dcOps > rsOps
81
+ ? `python-diskcache (${(dcOps/rsOps).toFixed(1)}x)`
82
+ : `diskcache_rs (${(rsOps/dcOps).toFixed(1)}x)`;
83
+ comment += `| ${name} | ${metric} | ${dcOps.toFixed(1)} ops/s | ${rsOps.toFixed(1)} ops/s | ${winner} |\n`;
84
+ };
93
85
 
94
- let winner;
95
- if (dcOps > rsOps) {
96
- winner = `python-diskcache (${(dcOps/rsOps).toFixed(1)}x)`;
97
- } else {
98
- winner = `diskcache_rs (${(rsOps/dcOps).toFixed(1)}x)`;
86
+ for (const [name, result] of Object.entries(results)) {
87
+ if (!result.diskcache || !result.diskcache_rs) continue;
88
+
89
+ const weighted = result.weighted_ops_per_sec || {};
90
+ addRow(name, 'weighted', weighted.diskcache, weighted.diskcache_rs);
91
+
92
+ for (const metric of ['get', 'set', 'delete']) {
93
+ addRow(
94
+ name,
95
+ metric,
96
+ result.diskcache[metric]?.ops_per_sec,
97
+ result.diskcache_rs[metric]?.ops_per_sec
98
+ );
99
99
  }
100
-
101
- comment += `| ${name} | ${dcOps.toFixed(1)} ops/s | ${rsOps.toFixed(1)} ops/s | ${winner} |\n`;
102
100
  }
103
101
 
104
102
  comment += '\n> 💡 **Note**: Performance varies based on storage type and network conditions.\n';
@@ -63,7 +63,14 @@ jobs:
63
63
  args: --release --out dist --find-interpreter
64
64
  sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
65
65
  manylinux: auto
66
- - uses: uraimo/run-on-arch-action@v3.0.1
66
+ - name: Pre-pull binfmt image
67
+ run: |
68
+ for attempt in 1 2 3; do
69
+ docker pull tonistiigi/binfmt:latest && break
70
+ if [ "$attempt" = "3" ]; then exit 1; fi
71
+ sleep $((attempt * 5))
72
+ done
73
+ - uses: uraimo/run-on-arch-action@v3.1.0
67
74
  if: matrix.target != 'ppc64le'
68
75
  name: Install built wheel
69
76
  with:
@@ -152,7 +159,14 @@ jobs:
152
159
  args: --release --out dist --find-interpreter
153
160
  sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
154
161
  manylinux: musllinux_1_2
155
- - uses: uraimo/run-on-arch-action@v3.0.1
162
+ - name: Pre-pull binfmt image
163
+ run: |
164
+ for attempt in 1 2 3; do
165
+ docker pull tonistiigi/binfmt:latest && break
166
+ if [ "$attempt" = "3" ]; then exit 1; fi
167
+ sleep $((attempt * 5))
168
+ done
169
+ - uses: uraimo/run-on-arch-action@v3.1.0
156
170
  name: Install built wheel
157
171
  with:
158
172
  arch: ${{ matrix.platform.arch }}
@@ -28,7 +28,7 @@ jobs:
28
28
  tag_name: ${{ steps.release.outputs.tag_name }}
29
29
  releases_created: ${{ steps.release.outputs.releases_created }}
30
30
  steps:
31
- - uses: googleapis/release-please-action@v4
31
+ - uses: googleapis/release-please-action@v5
32
32
  id: release
33
33
  with:
34
34
  token: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.4.10"
3
+ }
@@ -4,6 +4,13 @@
4
4
 
5
5
  - sync Cargo.toml version with .cz.toml and update CHANGELOG for v0.4.0
6
6
 
7
+ ## [0.4.10](https://github.com/loonghao/diskcache_rs/compare/diskcache_rs-v0.4.9...diskcache_rs-v0.4.10) (2026-04-15)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * **deps:** update rust crate redb to v4 ([910b7c4](https://github.com/loonghao/diskcache_rs/commit/910b7c4ac70fe4d2a3f0c81a8899ab6522f7f1b8))
13
+
7
14
  ## [0.4.9](https://github.com/loonghao/diskcache_rs/compare/diskcache_rs-v0.4.8...diskcache_rs-v0.4.9) (2026-03-25)
8
15
 
9
16
 
@@ -78,9 +78,9 @@ checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
78
78
 
79
79
  [[package]]
80
80
  name = "blake3"
81
- version = "1.8.3"
81
+ version = "1.8.4"
82
82
  source = "registry+https://github.com/rust-lang/crates.io-index"
83
- checksum = "2468ef7d57b3fb7e16b576e8377cdbde2320c60e1491e961d11da40fc4f02a2d"
83
+ checksum = "4d2d5991425dfd0785aed03aedcf0b321d61975c9b5b3689c774a2610ae0b51e"
84
84
  dependencies = [
85
85
  "arrayref",
86
86
  "arrayvec",
@@ -161,9 +161,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
161
161
 
162
162
  [[package]]
163
163
  name = "cpufeatures"
164
- version = "0.2.17"
164
+ version = "0.3.0"
165
165
  source = "registry+https://github.com/rust-lang/crates.io-index"
166
- checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
166
+ checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201"
167
167
  dependencies = [
168
168
  "libc",
169
169
  ]
@@ -246,7 +246,7 @@ dependencies = [
246
246
 
247
247
  [[package]]
248
248
  name = "diskcache_rs"
249
- version = "0.4.9"
249
+ version = "0.4.10"
250
250
  dependencies = [
251
251
  "anyhow",
252
252
  "bincode",
@@ -392,6 +392,15 @@ name = "hashbrown"
392
392
  version = "0.16.1"
393
393
  source = "registry+https://github.com/rust-lang/crates.io-index"
394
394
  checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
395
+ dependencies = [
396
+ "foldhash 0.2.0",
397
+ ]
398
+
399
+ [[package]]
400
+ name = "hashbrown"
401
+ version = "0.17.0"
402
+ source = "registry+https://github.com/rust-lang/crates.io-index"
403
+ checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51"
395
404
  dependencies = [
396
405
  "allocator-api2",
397
406
  "equivalent",
@@ -499,9 +508,9 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
499
508
 
500
509
  [[package]]
501
510
  name = "libc"
502
- version = "0.2.183"
511
+ version = "0.2.185"
503
512
  source = "registry+https://github.com/rust-lang/crates.io-index"
504
- checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
513
+ checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f"
505
514
 
506
515
  [[package]]
507
516
  name = "libsqlite3-sys"
@@ -537,18 +546,18 @@ checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
537
546
 
538
547
  [[package]]
539
548
  name = "lru"
540
- version = "0.16.3"
549
+ version = "0.18.0"
541
550
  source = "registry+https://github.com/rust-lang/crates.io-index"
542
- checksum = "a1dc47f592c06f33f8e3aea9591776ec7c9f9e4124778ff8a3c3b87159f7e593"
551
+ checksum = "8a860605968fce16869fd239cf4237a82f3ac470723415db603b0e8b6c8d4fb9"
543
552
  dependencies = [
544
- "hashbrown 0.16.1",
553
+ "hashbrown 0.17.0",
545
554
  ]
546
555
 
547
556
  [[package]]
548
557
  name = "lz4_flex"
549
- version = "0.13.0"
558
+ version = "0.13.1"
550
559
  source = "registry+https://github.com/rust-lang/crates.io-index"
551
- checksum = "db9a0d582c2874f68138a16ce1867e0ffde6c0bb0a0df85e1f36d04146db488a"
560
+ checksum = "7ef0d4ed8669f8f8826eb00dc878084aa8f253506c4fd5e8f58f5bce72ddb97e"
552
561
  dependencies = [
553
562
  "twox-hash",
554
563
  ]
@@ -683,9 +692,9 @@ dependencies = [
683
692
 
684
693
  [[package]]
685
694
  name = "pyo3"
686
- version = "0.28.2"
695
+ version = "0.28.3"
687
696
  source = "registry+https://github.com/rust-lang/crates.io-index"
688
- checksum = "cf85e27e86080aafd5a22eae58a162e133a589551542b3e5cee4beb27e54f8e1"
697
+ checksum = "91fd8e38a3b50ed1167fb981cd6fd60147e091784c427b8f7183a7ee32c31c12"
689
698
  dependencies = [
690
699
  "libc",
691
700
  "once_cell",
@@ -697,18 +706,18 @@ dependencies = [
697
706
 
698
707
  [[package]]
699
708
  name = "pyo3-build-config"
700
- version = "0.28.2"
709
+ version = "0.28.3"
701
710
  source = "registry+https://github.com/rust-lang/crates.io-index"
702
- checksum = "8bf94ee265674bf76c09fa430b0e99c26e319c945d96ca0d5a8215f31bf81cf7"
711
+ checksum = "e368e7ddfdeb98c9bca7f8383be1648fd84ab466bf2bc015e94008db6d35611e"
703
712
  dependencies = [
704
713
  "target-lexicon",
705
714
  ]
706
715
 
707
716
  [[package]]
708
717
  name = "pyo3-ffi"
709
- version = "0.28.2"
718
+ version = "0.28.3"
710
719
  source = "registry+https://github.com/rust-lang/crates.io-index"
711
- checksum = "491aa5fc66d8059dd44a75f4580a2962c1862a1c2945359db36f6c2818b748dc"
720
+ checksum = "7f29e10af80b1f7ccaf7f69eace800a03ecd13e883acfacc1e5d0988605f651e"
712
721
  dependencies = [
713
722
  "libc",
714
723
  "pyo3-build-config",
@@ -716,9 +725,9 @@ dependencies = [
716
725
 
717
726
  [[package]]
718
727
  name = "pyo3-macros"
719
- version = "0.28.2"
728
+ version = "0.28.3"
720
729
  source = "registry+https://github.com/rust-lang/crates.io-index"
721
- checksum = "f5d671734e9d7a43449f8480f8b38115df67bef8d21f76837fa75ee7aaa5e52e"
730
+ checksum = "df6e520eff47c45997d2fc7dd8214b25dd1310918bbb2642156ef66a67f29813"
722
731
  dependencies = [
723
732
  "proc-macro2",
724
733
  "pyo3-macros-backend",
@@ -728,9 +737,9 @@ dependencies = [
728
737
 
729
738
  [[package]]
730
739
  name = "pyo3-macros-backend"
731
- version = "0.28.2"
740
+ version = "0.28.3"
732
741
  source = "registry+https://github.com/rust-lang/crates.io-index"
733
- checksum = "22faaa1ce6c430a1f71658760497291065e6450d7b5dc2bcf254d49f66ee700a"
742
+ checksum = "c4cdc218d835738f81c2338f822078af45b4afdf8b2e33cbb5916f108b813acb"
734
743
  dependencies = [
735
744
  "heck",
736
745
  "proc-macro2",
@@ -756,9 +765,9 @@ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
756
765
 
757
766
  [[package]]
758
767
  name = "redb"
759
- version = "3.1.1"
768
+ version = "4.1.0"
760
769
  source = "registry+https://github.com/rust-lang/crates.io-index"
761
- checksum = "ef99362319c782aa4639ad3a306b64c3bb90e12874e99b8df124cb679d988611"
770
+ checksum = "8e925444704b5f17d32bf42f5b6e2df050bceebc3dcd6e71cc73dafe8092e839"
762
771
  dependencies = [
763
772
  "libc",
764
773
  ]
@@ -1052,9 +1061,9 @@ checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae"
1052
1061
 
1053
1062
  [[package]]
1054
1063
  name = "uuid"
1055
- version = "1.22.0"
1064
+ version = "1.23.1"
1056
1065
  source = "registry+https://github.com/rust-lang/crates.io-index"
1057
- checksum = "a68d3c8f01c0cfa54a75291d83601161799e4a89a39e0929f4b0354d88757a37"
1066
+ checksum = "ddd74a9687298c6858e9b88ec8935ec45d22e8fd5e6394fa1bd4e99a87789c76"
1058
1067
  dependencies = [
1059
1068
  "getrandom",
1060
1069
  "js-sys",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "diskcache_rs"
3
- version = "0.4.9"
3
+ version = "0.4.10"
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"
@@ -56,10 +56,10 @@ crossbeam = "0.8"
56
56
  # Cross-platform file locking for NFS support
57
57
  fs4 = "0.13"
58
58
 
59
- lru = "0.16"
59
+ lru = "0.18"
60
60
 
61
61
  # Embedded key-value database for persistent index
62
- redb = "3.1"
62
+ redb = "4.0"
63
63
 
64
64
  [lints.clippy]
65
65
  dbg_macro = "warn"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: diskcache_rs
3
- Version: 0.4.9
3
+ Version: 0.4.10
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: Apache Software License
@@ -198,6 +198,23 @@ def benchmark_large_values(cache_dir, implementation="diskcache", operations=100
198
198
  return results
199
199
 
200
200
 
201
+ def calculate_weighted_ops(benchmark_name, result):
202
+ """Calculate weighted throughput for the benchmark's operation mix."""
203
+ weights = (
204
+ {"get": 0.89, "set": 0.10, "delete": 0.01}
205
+ if "Standard Workload" in benchmark_name
206
+ else {"set": 0.50, "get": 0.50}
207
+ )
208
+ total = 0.0
209
+ total_weight = 0.0
210
+ for operation, weight in weights.items():
211
+ op_result = result.get(operation)
212
+ if op_result:
213
+ total += op_result["ops_per_sec"] * weight
214
+ total_weight += weight
215
+ return total / total_weight if total_weight else 0.0
216
+
217
+
201
218
  def run_benchmarks(test_dir):
202
219
  """Run all benchmarks following diskcache methodology"""
203
220
 
@@ -234,6 +251,10 @@ def run_benchmarks(test_dir):
234
251
  results[benchmark_name] = {
235
252
  "diskcache": diskcache_result,
236
253
  "diskcache_rs": diskcache_rs_result,
254
+ "weighted_ops_per_sec": {
255
+ "diskcache": calculate_weighted_ops(benchmark_name, diskcache_result),
256
+ "diskcache_rs": calculate_weighted_ops(benchmark_name, diskcache_rs_result),
257
+ },
237
258
  }
238
259
 
239
260
  # Print detailed comparison
@@ -308,6 +329,19 @@ def print_summary(results):
308
329
  for benchmark_name, result in results.items():
309
330
  dc_result = result["diskcache"]
310
331
  rs_result = result["diskcache_rs"]
332
+ weighted = result.get("weighted_ops_per_sec", {})
333
+ dc_weighted = weighted.get("diskcache", 0.0)
334
+ rs_weighted = weighted.get("diskcache_rs", 0.0)
335
+ if dc_weighted or rs_weighted:
336
+ winner = (
337
+ f"diskcache ({dc_weighted / rs_weighted:.1f}x)"
338
+ if dc_weighted > rs_weighted
339
+ else f"diskcache_rs ({rs_weighted / dc_weighted:.1f}x)"
340
+ )
341
+ bench_short = benchmark_name.split("(")[0].strip()
342
+ print(
343
+ f"{bench_short:<25} {'weighted':<8} {dc_weighted:>12.1f} ops/s {rs_weighted:>12.1f} ops/s {winner}"
344
+ )
311
345
 
312
346
  for operation in ["get", "set", "delete"]:
313
347
  if operation in dc_result and operation in rs_result:
@@ -46,11 +46,7 @@ except ImportError:
46
46
  # Version is exported from Rust core module
47
47
  from ._diskcache_rs import __version__
48
48
 
49
- # Optional: DjangoCache (only available if Django is installed and configured)
50
- try:
51
- from .djangocache import DjangoCache
52
- except Exception:
53
- pass
49
+ from .djangocache import DjangoCache
54
50
 
55
51
  __all__ = [
56
52
  # Core cache classes
@@ -86,6 +82,7 @@ __all__ = [
86
82
  "clear_cache",
87
83
  "FastCache",
88
84
  "FastFanoutCache",
85
+ "DjangoCache",
89
86
  "rust_pickle_dumps",
90
87
  "rust_pickle_loads",
91
88
  ]
@@ -6,7 +6,6 @@ with Python bindings, compatible with python-diskcache API.
6
6
  """
7
7
 
8
8
  import io
9
- from contextlib import contextmanager
10
9
  from pathlib import Path
11
10
  from typing import (
12
11
  Any,
@@ -29,7 +28,7 @@ __version__: str
29
28
  # ---------------------------------------------------------------------------
30
29
 
31
30
  class _Constant(tuple):
32
- def __new__(cls, name: str) -> "_Constant": ...
31
+ def __new__(cls, name: str) -> _Constant: ...
33
32
  def __repr__(self) -> str: ...
34
33
 
35
34
  ENOVAL: _Constant
@@ -50,14 +49,17 @@ EVICTION_POLICY: Dict[str, Dict[str, Optional[str]]]
50
49
 
51
50
  class Timeout(Exception):
52
51
  """Database timeout expired."""
52
+
53
53
  ...
54
54
 
55
55
  class EmptyDirWarning(UserWarning):
56
56
  """Warning for empty directories found during check."""
57
+
57
58
  ...
58
59
 
59
60
  class UnknownFileWarning(UserWarning):
60
61
  """Warning for unknown files found during check."""
62
+
61
63
  ...
62
64
 
63
65
  # Main Cache Classes
@@ -117,7 +119,6 @@ class Cache:
117
119
  tag: Optional[str] = None,
118
120
  ) -> int: ...
119
121
  def delete(self, key: Any, retry: bool = False) -> bool: ...
120
-
121
122
  def pop(
122
123
  self,
123
124
  key: Any,
@@ -354,8 +355,8 @@ class FanoutCache:
354
355
  def cache(
355
356
  self, name: str, timeout: Optional[float] = None, **kwargs: Any
356
357
  ) -> Cache: ...
357
- def deque(self, name: str, maxlen: Optional[int] = None) -> "Deque": ...
358
- def index(self, name: str) -> "Index": ...
358
+ def deque(self, name: str, maxlen: Optional[int] = None) -> Deque: ...
359
+ def index(self, name: str) -> Index: ...
359
360
 
360
361
  # Properties
361
362
  @property
@@ -365,6 +366,40 @@ class FanoutCache:
365
366
  @property
366
367
  def disk(self) -> Any: ...
367
368
 
369
+ class DjangoCache:
370
+ """Django cache backend backed by diskcache_rs.Cache."""
371
+
372
+ def __init__(self, location: str, params: Dict[str, Any]) -> None: ...
373
+ def add(
374
+ self,
375
+ key: str,
376
+ value: Any,
377
+ timeout: Any = ...,
378
+ version: Optional[int] = None,
379
+ ) -> bool: ...
380
+ def get(
381
+ self,
382
+ key: str,
383
+ default: Any = None,
384
+ version: Optional[int] = None,
385
+ ) -> Any: ...
386
+ def set(
387
+ self,
388
+ key: str,
389
+ value: Any,
390
+ timeout: Any = ...,
391
+ version: Optional[int] = None,
392
+ ) -> bool: ...
393
+ def touch(
394
+ self,
395
+ key: str,
396
+ timeout: Any = ...,
397
+ version: Optional[int] = None,
398
+ ) -> bool: ...
399
+ def delete(self, key: str, version: Optional[int] = None) -> bool: ...
400
+ def clear(self) -> bool: ...
401
+ def close(self, **kwargs: Any) -> None: ...
402
+
368
403
  class Deque:
369
404
  """Persistent double-ended queue based on Cache"""
370
405
 
@@ -384,7 +419,7 @@ class Deque:
384
419
  def extend(self, iterable: Any) -> None: ...
385
420
  def extendleft(self, iterable: Any) -> None: ...
386
421
  def close(self) -> None: ...
387
- def copy(self) -> "Deque": ...
422
+ def copy(self) -> Deque: ...
388
423
  def count(self, value: Any) -> int: ...
389
424
  def remove(self, value: Any) -> None: ...
390
425
  def reverse(self) -> None: ...
@@ -398,14 +433,14 @@ class Deque:
398
433
  def __getitem__(self, index: int) -> Any: ...
399
434
  def __setitem__(self, index: int, value: Any) -> None: ...
400
435
  def __delitem__(self, index: int) -> None: ...
401
- def __iadd__(self, other: Any) -> "Deque": ...
436
+ def __iadd__(self, other: Any) -> Deque: ...
402
437
  def __eq__(self, other: Any) -> bool: ...
403
438
  def __ne__(self, other: Any) -> bool: ...
404
439
  def __lt__(self, other: Any) -> bool: ...
405
440
  def __le__(self, other: Any) -> bool: ...
406
441
  def __gt__(self, other: Any) -> bool: ...
407
442
  def __ge__(self, other: Any) -> bool: ...
408
- def __enter__(self) -> "Deque": ...
443
+ def __enter__(self) -> Deque: ...
409
444
  def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None: ...
410
445
  def __getstate__(self) -> Tuple: ...
411
446
  def __setstate__(self, state: Tuple) -> None: ...
@@ -433,7 +468,7 @@ class Index:
433
468
  def __bool__(self) -> bool: ...
434
469
  def __eq__(self, other: Any) -> bool: ...
435
470
  def __ne__(self, other: Any) -> bool: ...
436
- def __enter__(self) -> "Index": ...
471
+ def __enter__(self) -> Index: ...
437
472
  def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None: ...
438
473
  def __getstate__(self) -> Tuple: ...
439
474
  def __setstate__(self, state: Tuple) -> None: ...
@@ -549,9 +584,7 @@ class Disk:
549
584
  def fetch(
550
585
  self, mode: int, filename: str, value: Any, read: bool = False
551
586
  ) -> Any: ...
552
- def filename(
553
- self, key: Any = ..., value: Any = ...
554
- ) -> Tuple[str, str]: ...
587
+ def filename(self, key: Any = ..., value: Any = ...) -> Tuple[str, str]: ...
555
588
  def remove(self, filename: str) -> None: ...
556
589
 
557
590
  class JSONDisk(Disk):
@@ -581,7 +614,7 @@ class Lock:
581
614
  def acquire(self) -> None: ...
582
615
  def release(self) -> None: ...
583
616
  def locked(self) -> bool: ...
584
- def __enter__(self) -> "Lock": ...
617
+ def __enter__(self) -> Lock: ...
585
618
  def __exit__(self, *exc_info: Any) -> None: ...
586
619
 
587
620
  class RLock:
@@ -596,7 +629,7 @@ class RLock:
596
629
  ) -> None: ...
597
630
  def acquire(self) -> None: ...
598
631
  def release(self) -> None: ...
599
- def __enter__(self) -> "RLock": ...
632
+ def __enter__(self) -> RLock: ...
600
633
  def __exit__(self, *exc_info: Any) -> None: ...
601
634
 
602
635
  class BoundedSemaphore:
@@ -612,7 +645,7 @@ class BoundedSemaphore:
612
645
  ) -> None: ...
613
646
  def acquire(self) -> None: ...
614
647
  def release(self) -> None: ...
615
- def __enter__(self) -> "BoundedSemaphore": ...
648
+ def __enter__(self) -> BoundedSemaphore: ...
616
649
  def __exit__(self, *exc_info: Any) -> None: ...
617
650
 
618
651
  class Averager:
@@ -643,7 +676,6 @@ def throttle(
643
676
  time_func: Callable[[], float] = ...,
644
677
  sleep_func: Callable[[float], None] = ...,
645
678
  ) -> Callable: ...
646
-
647
679
  def barrier(
648
680
  cache: Cache,
649
681
  lock_factory: Type[Union[Lock, RLock, BoundedSemaphore]],
@@ -651,7 +683,6 @@ def barrier(
651
683
  expire: Optional[float] = None,
652
684
  tag: Optional[str] = None,
653
685
  ) -> Callable: ...
654
-
655
686
  def memoize_stampede(
656
687
  cache: Cache,
657
688
  expire: float,
@@ -714,6 +745,7 @@ __all__ = [
714
745
  # diskcache_rs extras
715
746
  "FastCache",
716
747
  "FastFanoutCache",
748
+ "DjangoCache",
717
749
  "PickleCache",
718
750
  "cache_object",
719
751
  "get_cached_object",
@@ -21,6 +21,8 @@ except ImportError:
21
21
 
22
22
  # We'll import the Rust implementation at runtime to avoid circular imports
23
23
  _RustCache = None
24
+ _RAW_BYTES_PREFIX = b"\x00diskcache_rs:bytes\x00"
25
+ _PICKLE_PREFIX = b"\x00diskcache_rs:pickle\x00"
24
26
 
25
27
 
26
28
  def _get_rust_cache():
@@ -57,8 +59,8 @@ class Cache:
57
59
  **kwargs: Additional arguments:
58
60
  - max_size / size_limit: Maximum cache size in bytes (default: 1GB)
59
61
  - max_entries / count_limit: Maximum number of entries (default: 100,000)
60
- - disk_write_threshold: Size threshold for writing to disk vs memory-only (default: 1024 bytes)
61
- Items smaller than this threshold are stored in memory only and won't create disk files.
62
+ - disk_write_threshold: Size threshold for writing to disk vs inline SQLite (default: 32768 bytes)
63
+ Items smaller than this threshold are stored inline and won't create data files.
62
64
  Set to 0 to write all items to disk (useful for testing/debugging).
63
65
  - use_file_locking: Enable file locking for NFS scenarios (default: False)
64
66
  Enable this when using cache on network filesystems to prevent corruption.
@@ -82,7 +84,7 @@ class Cache:
82
84
  max_entries = kwargs.get("count_limit", kwargs.get("max_entries", 100_000))
83
85
 
84
86
  # New configuration options for issue #17
85
- disk_write_threshold = kwargs.get("disk_write_threshold", 1024) # 1KB default
87
+ disk_write_threshold = kwargs.get("disk_write_threshold", disk_min_file_size)
86
88
  use_file_locking = kwargs.get("use_file_locking", False)
87
89
 
88
90
  # Create the underlying Rust cache
@@ -124,7 +126,7 @@ class Cache:
124
126
  value = value.read()
125
127
 
126
128
  # Serialize the value
127
- serialized_value = pickle.dumps(value)
129
+ serialized_value = self._serialize_value(value)
128
130
 
129
131
  # Calculate expiration time
130
132
  expire_time = None
@@ -180,7 +182,7 @@ class Cache:
180
182
 
181
183
  serialized_items = []
182
184
  for key, value in normalized_items:
183
- serialized_items.append((str(key), pickle.dumps(value)))
185
+ serialized_items.append((str(key), self._serialize_value(value)))
184
186
 
185
187
  tags = [tag] if tag else []
186
188
  self._cache.set_many(serialized_items, expire_time=expire_time, tags=tags)
@@ -201,6 +203,11 @@ class Cache:
201
203
  except Exception:
202
204
  return 0
203
205
 
206
+ def _serialize_value(self, value: Any) -> bytes:
207
+ if type(value) is bytes:
208
+ return _RAW_BYTES_PREFIX + value
209
+ return _PICKLE_PREFIX + pickle.dumps(value)
210
+
204
211
  def _auto_deserialize(self, data: bytes) -> Any:
205
212
 
206
213
  """
@@ -217,7 +224,13 @@ class Cache:
217
224
  Returns:
218
225
  Deserialized value
219
226
  """
220
- # Try pickle first (most common)
227
+ if data.startswith(_RAW_BYTES_PREFIX):
228
+ return data[len(_RAW_BYTES_PREFIX) :]
229
+
230
+ if data.startswith(_PICKLE_PREFIX):
231
+ return pickle.loads(data[len(_PICKLE_PREFIX) :])
232
+
233
+ # Try pickle first (legacy format)
221
234
  try:
222
235
  return pickle.loads(data)
223
236
  except Exception: