diskcache-rs 0.4.3__tar.gz → 0.4.5__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.
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/.github/actions/build-and-test/action.yml +1 -1
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/.github/actions/setup-diskcache-rs/action.yml +2 -2
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/.github/workflows/benchmark.yml +1 -1
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/.github/workflows/build-abi3.yml +4 -4
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/.github/workflows/build.yml +6 -6
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/.github/workflows/release.yml +2 -2
- diskcache_rs-0.4.5/.release-please-manifest.json +3 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/CHANGELOG.md +19 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/Cargo.lock +63 -74
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/Cargo.toml +2 -2
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/PKG-INFO +1 -1
- diskcache_rs-0.4.5/examples/special_chars_keys_example.py +107 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/python/diskcache_rs/cache.py +42 -2
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/src/utils.rs +21 -9
- diskcache_rs-0.4.5/tests/test_special_chars_keys.py +182 -0
- diskcache_rs-0.4.3/.release-please-manifest.json +0 -3
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/.github/pull_request_template.md +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/.github/workflows/ci.yml +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/.gitignore +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/.pre-commit-config.yaml +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/API_COMPATIBILITY.md +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/Dockerfile.test +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/LICENSE +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/README.md +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/benchmarks/comprehensive_performance_test.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/benchmarks/detailed_profiling.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/benchmarks/final_performance_comparison.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/benchmarks/high_performance_test.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/benchmarks/memory_usage_test.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/benchmarks/micro_benchmark.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/benchmarks/optimization_validation_test.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/benchmarks/performance_comparison.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/benchmarks/precise_benchmark.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/benchmarks/set_performance_analysis.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/docker-compose.test.yml +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/examples/basic_usage.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/justfile +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/pyproject.toml +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/python/diskcache_rs/__init__.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/python/diskcache_rs/__init__.pyi +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/python/diskcache_rs/_diskcache_rs.pyi +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/python/diskcache_rs/core.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/python/diskcache_rs/fast_cache.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/python/diskcache_rs/pickle_cache.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/python/diskcache_rs/rust_pickle.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/release-please-config.json +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/renovate.json +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/scripts/generate_stubs.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/scripts/sync_version.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/scripts/test-docker-network.sh +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/src/cache.rs +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/src/error.rs +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/src/eviction.rs +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/src/lib.rs +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/src/memory_cache.rs +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/src/migration.rs +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/src/pickle_cache.rs +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/src/serialization.rs +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/src/storage/optimized_backend.rs +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/src/storage/tests.rs +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/src/storage.rs +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/tests/__init__.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/tests/benchmark_official.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/tests/conftest.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/tests/test_api_compatibility.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/tests/test_basic_operations.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/tests/test_ci_benchmark.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/tests/test_compatibility.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/tests/test_cross_platform_network.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/tests/test_diskcache_rs_persistence_suite.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/tests/test_docker_network.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/tests/test_fast_cache.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/tests/test_issue_17_configurable_threshold.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/tests/test_network_filesystem.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/tests/test_performance.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/tests/test_pickle_cache.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/tests/test_rust_pickle_performance.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/tests/test_version_and_disk_threshold.py +0 -0
- {diskcache_rs-0.4.3 → diskcache_rs-0.4.5}/uv.lock +0 -0
|
@@ -28,7 +28,7 @@ runs:
|
|
|
28
28
|
components: ${{ inputs.rust-components }}
|
|
29
29
|
|
|
30
30
|
- name: Cache Rust dependencies
|
|
31
|
-
uses: actions/cache@
|
|
31
|
+
uses: actions/cache@v5
|
|
32
32
|
with:
|
|
33
33
|
path: |
|
|
34
34
|
~/.cargo/bin/
|
|
@@ -36,7 +36,7 @@ runs:
|
|
|
36
36
|
~/.cargo/registry/cache/
|
|
37
37
|
~/.cargo/git/db/
|
|
38
38
|
target/
|
|
39
|
-
key: ${{ runner.os }}-cargo-${{ inputs.cache-key-suffix }}-${{ hashFiles('
|
|
39
|
+
key: ${{ runner.os }}-cargo-${{ inputs.cache-key-suffix }}-${{ hashFiles('Cargo.lock') }}
|
|
40
40
|
restore-keys: |
|
|
41
41
|
${{ runner.os }}-cargo-${{ inputs.cache-key-suffix }}-
|
|
42
42
|
${{ runner.os }}-cargo-
|
|
@@ -37,7 +37,7 @@ jobs:
|
|
|
37
37
|
pip install diskcache_rs --find-links dist --force-reinstall
|
|
38
38
|
python -c "import diskcache_rs; print('diskcache_rs imported successfully')"
|
|
39
39
|
- name: Upload wheels
|
|
40
|
-
uses: actions/upload-artifact@
|
|
40
|
+
uses: actions/upload-artifact@v6
|
|
41
41
|
with:
|
|
42
42
|
name: wheels-linux-abi3-${{ matrix.target }}
|
|
43
43
|
path: dist
|
|
@@ -66,7 +66,7 @@ jobs:
|
|
|
66
66
|
pip install diskcache_rs --find-links dist --force-reinstall
|
|
67
67
|
python -c "import diskcache_rs; print('diskcache_rs imported successfully')"
|
|
68
68
|
- name: Upload wheels
|
|
69
|
-
uses: actions/upload-artifact@
|
|
69
|
+
uses: actions/upload-artifact@v6
|
|
70
70
|
with:
|
|
71
71
|
name: wheels-windows-abi3-${{ matrix.target }}
|
|
72
72
|
path: dist
|
|
@@ -95,7 +95,7 @@ jobs:
|
|
|
95
95
|
pip install diskcache_rs --find-links dist --force-reinstall
|
|
96
96
|
python -c "import diskcache_rs; print('diskcache_rs imported successfully')"
|
|
97
97
|
- name: Upload wheels
|
|
98
|
-
uses: actions/upload-artifact@
|
|
98
|
+
uses: actions/upload-artifact@v6
|
|
99
99
|
with:
|
|
100
100
|
name: wheels-macos-abi3-${{ matrix.target }}
|
|
101
101
|
path: dist
|
|
@@ -111,7 +111,7 @@ jobs:
|
|
|
111
111
|
command: sdist
|
|
112
112
|
args: --out dist
|
|
113
113
|
- name: Upload sdist
|
|
114
|
-
uses: actions/upload-artifact@
|
|
114
|
+
uses: actions/upload-artifact@v6
|
|
115
115
|
with:
|
|
116
116
|
name: wheels-sdist-abi3
|
|
117
117
|
path: dist
|
|
@@ -40,7 +40,7 @@ jobs:
|
|
|
40
40
|
pip install diskcache_rs --find-links dist --force-reinstall
|
|
41
41
|
python -c "import diskcache_rs; print('diskcache_rs imported successfully')"
|
|
42
42
|
- name: Upload wheels
|
|
43
|
-
uses: actions/upload-artifact@
|
|
43
|
+
uses: actions/upload-artifact@v6
|
|
44
44
|
with:
|
|
45
45
|
name: wheels-linux-${{ matrix.target }}
|
|
46
46
|
path: dist
|
|
@@ -79,7 +79,7 @@ jobs:
|
|
|
79
79
|
uv pip install diskcache_rs --find-links dist/ --force-reinstall --system
|
|
80
80
|
python3 -c "import diskcache_rs; print('diskcache_rs imported successfully')"
|
|
81
81
|
- name: Upload wheels
|
|
82
|
-
uses: actions/upload-artifact@
|
|
82
|
+
uses: actions/upload-artifact@v6
|
|
83
83
|
with:
|
|
84
84
|
name: wheels-linux-cross-${{ matrix.target }}
|
|
85
85
|
path: dist
|
|
@@ -125,7 +125,7 @@ jobs:
|
|
|
125
125
|
fi
|
|
126
126
|
python3 -c "import diskcache_rs; print('diskcache_rs imported successfully')"
|
|
127
127
|
- name: Upload wheels
|
|
128
|
-
uses: actions/upload-artifact@
|
|
128
|
+
uses: actions/upload-artifact@v6
|
|
129
129
|
with:
|
|
130
130
|
name: wheels-musllinux-${{ matrix.target }}
|
|
131
131
|
path: dist
|
|
@@ -173,7 +173,7 @@ jobs:
|
|
|
173
173
|
fi
|
|
174
174
|
python3 -c "import diskcache_rs; print('diskcache_rs imported successfully')"
|
|
175
175
|
- name: Upload wheels
|
|
176
|
-
uses: actions/upload-artifact@
|
|
176
|
+
uses: actions/upload-artifact@v6
|
|
177
177
|
with:
|
|
178
178
|
name: wheels-musllinux-cross-${{ matrix.platform.target }}
|
|
179
179
|
path: dist
|
|
@@ -202,7 +202,7 @@ jobs:
|
|
|
202
202
|
pip install diskcache_rs --find-links dist --force-reinstall
|
|
203
203
|
python -c "import diskcache_rs; print('diskcache_rs imported successfully')"
|
|
204
204
|
- name: Upload wheels
|
|
205
|
-
uses: actions/upload-artifact@
|
|
205
|
+
uses: actions/upload-artifact@v6
|
|
206
206
|
with:
|
|
207
207
|
name: wheels-windows-${{ matrix.target }}
|
|
208
208
|
path: dist
|
|
@@ -238,7 +238,7 @@ jobs:
|
|
|
238
238
|
pip install diskcache_rs --find-links dist --force-reinstall
|
|
239
239
|
python -c "import diskcache_rs; print('diskcache_rs imported successfully')"
|
|
240
240
|
- name: Upload wheels
|
|
241
|
-
uses: actions/upload-artifact@
|
|
241
|
+
uses: actions/upload-artifact@v6
|
|
242
242
|
with:
|
|
243
243
|
name: wheels-macos
|
|
244
244
|
path: dist
|
|
@@ -80,7 +80,7 @@ jobs:
|
|
|
80
80
|
|
|
81
81
|
steps:
|
|
82
82
|
- name: Download all artifacts
|
|
83
|
-
uses: actions/download-artifact@
|
|
83
|
+
uses: actions/download-artifact@v7
|
|
84
84
|
with:
|
|
85
85
|
path: dist
|
|
86
86
|
merge-multiple: true
|
|
@@ -143,7 +143,7 @@ jobs:
|
|
|
143
143
|
{{__unknown__}}
|
|
144
144
|
|
|
145
145
|
- name: Download all artifacts
|
|
146
|
-
uses: actions/download-artifact@
|
|
146
|
+
uses: actions/download-artifact@v7
|
|
147
147
|
with:
|
|
148
148
|
path: release-artifacts
|
|
149
149
|
merge-multiple: true
|
|
@@ -4,6 +4,25 @@
|
|
|
4
4
|
|
|
5
5
|
- sync Cargo.toml version with .cz.toml and update CHANGELOG for v0.4.0
|
|
6
6
|
|
|
7
|
+
## [0.4.5](https://github.com/loonghao/diskcache_rs/compare/diskcache_rs-v0.4.4...diskcache_rs-v0.4.5) (2025-12-29)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* **deps:** update rust crate rusqlite to 0.38 ([22f31e5](https://github.com/loonghao/diskcache_rs/commit/22f31e5615806a512e9813e0a14e0f5d916bbad8))
|
|
13
|
+
|
|
14
|
+
## [0.4.4](https://github.com/loonghao/diskcache_rs/compare/diskcache_rs-v0.4.3...diskcache_rs-v0.4.4) (2025-11-22)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* support special characters in cache keys and auto-deserialization ([e56ad93](https://github.com/loonghao/diskcache_rs/commit/e56ad939b1c95456929d46887441c8d8610f1476))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* resolve hashFiles path issue in GitHub Actions for macOS ([08abc64](https://github.com/loonghao/diskcache_rs/commit/08abc6442b2c7208b26038f28be07ab31dbccbe7))
|
|
25
|
+
|
|
7
26
|
## [0.4.3](https://github.com/loonghao/diskcache_rs/compare/diskcache_rs-v0.4.2...diskcache_rs-v0.4.3) (2025-11-22)
|
|
8
27
|
|
|
9
28
|
|
|
@@ -236,7 +236,7 @@ dependencies = [
|
|
|
236
236
|
|
|
237
237
|
[[package]]
|
|
238
238
|
name = "diskcache_rs"
|
|
239
|
-
version = "0.4.
|
|
239
|
+
version = "0.4.5"
|
|
240
240
|
dependencies = [
|
|
241
241
|
"anyhow",
|
|
242
242
|
"bincode",
|
|
@@ -291,7 +291,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
|
291
291
|
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
|
292
292
|
dependencies = [
|
|
293
293
|
"libc",
|
|
294
|
-
"windows-sys
|
|
294
|
+
"windows-sys",
|
|
295
295
|
]
|
|
296
296
|
|
|
297
297
|
[[package]]
|
|
@@ -318,12 +318,6 @@ version = "0.1.5"
|
|
|
318
318
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
319
319
|
checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844"
|
|
320
320
|
|
|
321
|
-
[[package]]
|
|
322
|
-
name = "foldhash"
|
|
323
|
-
version = "0.1.5"
|
|
324
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
325
|
-
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
|
|
326
|
-
|
|
327
321
|
[[package]]
|
|
328
322
|
name = "foldhash"
|
|
329
323
|
version = "0.2.0"
|
|
@@ -337,7 +331,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
|
337
331
|
checksum = "8640e34b88f7652208ce9e88b1a37a2ae95227d84abec377ccd3c5cfeb141ed4"
|
|
338
332
|
dependencies = [
|
|
339
333
|
"rustix",
|
|
340
|
-
"windows-sys
|
|
334
|
+
"windows-sys",
|
|
341
335
|
]
|
|
342
336
|
|
|
343
337
|
[[package]]
|
|
@@ -367,15 +361,6 @@ version = "0.14.5"
|
|
|
367
361
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
368
362
|
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
|
369
363
|
|
|
370
|
-
[[package]]
|
|
371
|
-
name = "hashbrown"
|
|
372
|
-
version = "0.15.5"
|
|
373
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
374
|
-
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
|
|
375
|
-
dependencies = [
|
|
376
|
-
"foldhash 0.1.5",
|
|
377
|
-
]
|
|
378
|
-
|
|
379
364
|
[[package]]
|
|
380
365
|
name = "hashbrown"
|
|
381
366
|
version = "0.16.1"
|
|
@@ -384,16 +369,16 @@ checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
|
|
|
384
369
|
dependencies = [
|
|
385
370
|
"allocator-api2",
|
|
386
371
|
"equivalent",
|
|
387
|
-
"foldhash
|
|
372
|
+
"foldhash",
|
|
388
373
|
]
|
|
389
374
|
|
|
390
375
|
[[package]]
|
|
391
376
|
name = "hashlink"
|
|
392
|
-
version = "0.
|
|
377
|
+
version = "0.11.0"
|
|
393
378
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
394
|
-
checksum = "
|
|
379
|
+
checksum = "ea0b22561a9c04a7cb1a302c013e0259cd3b4bb619f145b32f72b8b4bcbed230"
|
|
395
380
|
dependencies = [
|
|
396
|
-
"hashbrown 0.
|
|
381
|
+
"hashbrown 0.16.1",
|
|
397
382
|
]
|
|
398
383
|
|
|
399
384
|
[[package]]
|
|
@@ -473,15 +458,15 @@ dependencies = [
|
|
|
473
458
|
|
|
474
459
|
[[package]]
|
|
475
460
|
name = "libc"
|
|
476
|
-
version = "0.2.
|
|
461
|
+
version = "0.2.179"
|
|
477
462
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
478
|
-
checksum = "
|
|
463
|
+
checksum = "c5a2d376baa530d1238d133232d15e239abad80d05838b4b59354e5268af431f"
|
|
479
464
|
|
|
480
465
|
[[package]]
|
|
481
466
|
name = "libsqlite3-sys"
|
|
482
|
-
version = "0.
|
|
467
|
+
version = "0.36.0"
|
|
483
468
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
484
|
-
checksum = "
|
|
469
|
+
checksum = "95b4103cffefa72eb8428cb6b47d6627161e51c2739fc5e3b734584157bc642a"
|
|
485
470
|
dependencies = [
|
|
486
471
|
"cc",
|
|
487
472
|
"pkg-config",
|
|
@@ -656,9 +641,9 @@ dependencies = [
|
|
|
656
641
|
|
|
657
642
|
[[package]]
|
|
658
643
|
name = "pyo3"
|
|
659
|
-
version = "0.27.
|
|
644
|
+
version = "0.27.2"
|
|
660
645
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
661
|
-
checksum = "
|
|
646
|
+
checksum = "ab53c047fcd1a1d2a8820fe84f05d6be69e9526be40cb03b73f86b6b03e6d87d"
|
|
662
647
|
dependencies = [
|
|
663
648
|
"indoc",
|
|
664
649
|
"libc",
|
|
@@ -673,18 +658,18 @@ dependencies = [
|
|
|
673
658
|
|
|
674
659
|
[[package]]
|
|
675
660
|
name = "pyo3-build-config"
|
|
676
|
-
version = "0.27.
|
|
661
|
+
version = "0.27.2"
|
|
677
662
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
678
|
-
checksum = "
|
|
663
|
+
checksum = "b455933107de8642b4487ed26d912c2d899dec6114884214a0b3bb3be9261ea6"
|
|
679
664
|
dependencies = [
|
|
680
665
|
"target-lexicon",
|
|
681
666
|
]
|
|
682
667
|
|
|
683
668
|
[[package]]
|
|
684
669
|
name = "pyo3-ffi"
|
|
685
|
-
version = "0.27.
|
|
670
|
+
version = "0.27.2"
|
|
686
671
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
687
|
-
checksum = "
|
|
672
|
+
checksum = "1c85c9cbfaddf651b1221594209aed57e9e5cff63c4d11d1feead529b872a089"
|
|
688
673
|
dependencies = [
|
|
689
674
|
"libc",
|
|
690
675
|
"pyo3-build-config",
|
|
@@ -692,9 +677,9 @@ dependencies = [
|
|
|
692
677
|
|
|
693
678
|
[[package]]
|
|
694
679
|
name = "pyo3-macros"
|
|
695
|
-
version = "0.27.
|
|
680
|
+
version = "0.27.2"
|
|
696
681
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
697
|
-
checksum = "
|
|
682
|
+
checksum = "0a5b10c9bf9888125d917fb4d2ca2d25c8df94c7ab5a52e13313a07e050a3b02"
|
|
698
683
|
dependencies = [
|
|
699
684
|
"proc-macro2",
|
|
700
685
|
"pyo3-macros-backend",
|
|
@@ -704,9 +689,9 @@ dependencies = [
|
|
|
704
689
|
|
|
705
690
|
[[package]]
|
|
706
691
|
name = "pyo3-macros-backend"
|
|
707
|
-
version = "0.27.
|
|
692
|
+
version = "0.27.2"
|
|
708
693
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
709
|
-
checksum = "
|
|
694
|
+
checksum = "03b51720d314836e53327f5871d4c0cfb4fb37cc2c4a11cc71907a86342c40f9"
|
|
710
695
|
dependencies = [
|
|
711
696
|
"heck",
|
|
712
697
|
"proc-macro2",
|
|
@@ -761,20 +746,19 @@ dependencies = [
|
|
|
761
746
|
|
|
762
747
|
[[package]]
|
|
763
748
|
name = "rmp-serde"
|
|
764
|
-
version = "1.3.
|
|
749
|
+
version = "1.3.1"
|
|
765
750
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
766
|
-
checksum = "
|
|
751
|
+
checksum = "72f81bee8c8ef9b577d1681a70ebbc962c232461e397b22c208c43c04b67a155"
|
|
767
752
|
dependencies = [
|
|
768
|
-
"byteorder",
|
|
769
753
|
"rmp",
|
|
770
754
|
"serde",
|
|
771
755
|
]
|
|
772
756
|
|
|
773
757
|
[[package]]
|
|
774
758
|
name = "rusqlite"
|
|
775
|
-
version = "0.
|
|
759
|
+
version = "0.38.0"
|
|
776
760
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
777
|
-
checksum = "
|
|
761
|
+
checksum = "f1c93dd1c9683b438c392c492109cb702b8090b2bfc8fed6f6e4eb4523f17af3"
|
|
778
762
|
dependencies = [
|
|
779
763
|
"bitflags",
|
|
780
764
|
"chrono",
|
|
@@ -783,6 +767,7 @@ dependencies = [
|
|
|
783
767
|
"hashlink",
|
|
784
768
|
"libsqlite3-sys",
|
|
785
769
|
"smallvec",
|
|
770
|
+
"sqlite-wasm-rs",
|
|
786
771
|
]
|
|
787
772
|
|
|
788
773
|
[[package]]
|
|
@@ -796,15 +781,15 @@ dependencies = [
|
|
|
796
781
|
|
|
797
782
|
[[package]]
|
|
798
783
|
name = "rustix"
|
|
799
|
-
version = "1.1.
|
|
784
|
+
version = "1.1.3"
|
|
800
785
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
801
|
-
checksum = "
|
|
786
|
+
checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34"
|
|
802
787
|
dependencies = [
|
|
803
788
|
"bitflags",
|
|
804
789
|
"errno",
|
|
805
790
|
"libc",
|
|
806
791
|
"linux-raw-sys",
|
|
807
|
-
"windows-sys
|
|
792
|
+
"windows-sys",
|
|
808
793
|
]
|
|
809
794
|
|
|
810
795
|
[[package]]
|
|
@@ -813,12 +798,6 @@ version = "1.0.22"
|
|
|
813
798
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
814
799
|
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
|
815
800
|
|
|
816
|
-
[[package]]
|
|
817
|
-
name = "ryu"
|
|
818
|
-
version = "1.0.20"
|
|
819
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
820
|
-
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
|
821
|
-
|
|
822
801
|
[[package]]
|
|
823
802
|
name = "scopeguard"
|
|
824
803
|
version = "1.2.0"
|
|
@@ -876,15 +855,15 @@ dependencies = [
|
|
|
876
855
|
|
|
877
856
|
[[package]]
|
|
878
857
|
name = "serde_json"
|
|
879
|
-
version = "1.0.
|
|
858
|
+
version = "1.0.148"
|
|
880
859
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
881
|
-
checksum = "
|
|
860
|
+
checksum = "3084b546a1dd6289475996f182a22aba973866ea8e8b02c51d9f46b1336a22da"
|
|
882
861
|
dependencies = [
|
|
883
862
|
"itoa",
|
|
884
863
|
"memchr",
|
|
885
|
-
"ryu",
|
|
886
864
|
"serde",
|
|
887
865
|
"serde_core",
|
|
866
|
+
"zmij",
|
|
888
867
|
]
|
|
889
868
|
|
|
890
869
|
[[package]]
|
|
@@ -908,6 +887,19 @@ dependencies = [
|
|
|
908
887
|
"lock_api",
|
|
909
888
|
]
|
|
910
889
|
|
|
890
|
+
[[package]]
|
|
891
|
+
name = "sqlite-wasm-rs"
|
|
892
|
+
version = "0.5.1"
|
|
893
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
894
|
+
checksum = "05e98301bf8b0540c7de45ecd760539b9c62f5772aed172f08efba597c11cd5d"
|
|
895
|
+
dependencies = [
|
|
896
|
+
"cc",
|
|
897
|
+
"hashbrown 0.16.1",
|
|
898
|
+
"js-sys",
|
|
899
|
+
"thiserror",
|
|
900
|
+
"wasm-bindgen",
|
|
901
|
+
]
|
|
902
|
+
|
|
911
903
|
[[package]]
|
|
912
904
|
name = "stable_deref_trait"
|
|
913
905
|
version = "1.2.1"
|
|
@@ -933,15 +925,15 @@ checksum = "df7f62577c25e07834649fc3b39fafdc597c0a3527dc1c60129201ccfcbaa50c"
|
|
|
933
925
|
|
|
934
926
|
[[package]]
|
|
935
927
|
name = "tempfile"
|
|
936
|
-
version = "3.
|
|
928
|
+
version = "3.24.0"
|
|
937
929
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
938
|
-
checksum = "
|
|
930
|
+
checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c"
|
|
939
931
|
dependencies = [
|
|
940
932
|
"fastrand",
|
|
941
933
|
"getrandom",
|
|
942
934
|
"once_cell",
|
|
943
935
|
"rustix",
|
|
944
|
-
"windows-sys
|
|
936
|
+
"windows-sys",
|
|
945
937
|
]
|
|
946
938
|
|
|
947
939
|
[[package]]
|
|
@@ -966,9 +958,9 @@ dependencies = [
|
|
|
966
958
|
|
|
967
959
|
[[package]]
|
|
968
960
|
name = "tracing"
|
|
969
|
-
version = "0.1.
|
|
961
|
+
version = "0.1.44"
|
|
970
962
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
971
|
-
checksum = "
|
|
963
|
+
checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
|
|
972
964
|
dependencies = [
|
|
973
965
|
"pin-project-lite",
|
|
974
966
|
"tracing-attributes",
|
|
@@ -977,9 +969,9 @@ dependencies = [
|
|
|
977
969
|
|
|
978
970
|
[[package]]
|
|
979
971
|
name = "tracing-attributes"
|
|
980
|
-
version = "0.1.
|
|
972
|
+
version = "0.1.31"
|
|
981
973
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
982
|
-
checksum = "
|
|
974
|
+
checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"
|
|
983
975
|
dependencies = [
|
|
984
976
|
"proc-macro2",
|
|
985
977
|
"quote",
|
|
@@ -988,9 +980,9 @@ dependencies = [
|
|
|
988
980
|
|
|
989
981
|
[[package]]
|
|
990
982
|
name = "tracing-core"
|
|
991
|
-
version = "0.1.
|
|
983
|
+
version = "0.1.36"
|
|
992
984
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
993
|
-
checksum = "
|
|
985
|
+
checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"
|
|
994
986
|
dependencies = [
|
|
995
987
|
"once_cell",
|
|
996
988
|
]
|
|
@@ -1021,13 +1013,13 @@ checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae"
|
|
|
1021
1013
|
|
|
1022
1014
|
[[package]]
|
|
1023
1015
|
name = "uuid"
|
|
1024
|
-
version = "1.
|
|
1016
|
+
version = "1.19.0"
|
|
1025
1017
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1026
|
-
checksum = "
|
|
1018
|
+
checksum = "e2e054861b4bd027cd373e18e8d8d8e6548085000e41290d95ce0c373a654b4a"
|
|
1027
1019
|
dependencies = [
|
|
1028
1020
|
"getrandom",
|
|
1029
1021
|
"js-sys",
|
|
1030
|
-
"
|
|
1022
|
+
"serde_core",
|
|
1031
1023
|
"wasm-bindgen",
|
|
1032
1024
|
]
|
|
1033
1025
|
|
|
@@ -1187,15 +1179,6 @@ dependencies = [
|
|
|
1187
1179
|
"windows-targets",
|
|
1188
1180
|
]
|
|
1189
1181
|
|
|
1190
|
-
[[package]]
|
|
1191
|
-
name = "windows-sys"
|
|
1192
|
-
version = "0.61.2"
|
|
1193
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1194
|
-
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
|
1195
|
-
dependencies = [
|
|
1196
|
-
"windows-link",
|
|
1197
|
-
]
|
|
1198
|
-
|
|
1199
1182
|
[[package]]
|
|
1200
1183
|
name = "windows-targets"
|
|
1201
1184
|
version = "0.52.6"
|
|
@@ -1265,3 +1248,9 @@ name = "wit-bindgen"
|
|
|
1265
1248
|
version = "0.46.0"
|
|
1266
1249
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1267
1250
|
checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
|
|
1251
|
+
|
|
1252
|
+
[[package]]
|
|
1253
|
+
name = "zmij"
|
|
1254
|
+
version = "1.0.0"
|
|
1255
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1256
|
+
checksum = "e6d6085d62852e35540689d1f97ad663e3971fc19cf5eceab364d62c646ea167"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "diskcache_rs"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.5"
|
|
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"
|
|
@@ -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
|
+
rusqlite = { version = "0.38", features = ["bundled", "blob", "chrono"] }
|
|
40
40
|
|
|
41
41
|
# tokio removed - using std::thread instead for simplicity
|
|
42
42
|
parking_lot = "0.12"
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Example demonstrating support for special characters in cache keys
|
|
3
|
+
|
|
4
|
+
This example shows how diskcache_rs now supports keys containing
|
|
5
|
+
special characters like :, /, \\, . and more.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import tempfile
|
|
9
|
+
from diskcache_rs import Cache
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def main():
|
|
13
|
+
# Create a temporary cache directory
|
|
14
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
15
|
+
cache = Cache(tmpdir)
|
|
16
|
+
|
|
17
|
+
print("=" * 60)
|
|
18
|
+
print("diskcache_rs - Special Characters in Keys Support")
|
|
19
|
+
print("=" * 60)
|
|
20
|
+
print()
|
|
21
|
+
|
|
22
|
+
# Example 1: URL as cache key
|
|
23
|
+
print("1. Using URLs as cache keys:")
|
|
24
|
+
url = "https://api.example.com/v1/users/123?include=profile"
|
|
25
|
+
response_data = {
|
|
26
|
+
"user_id": 123,
|
|
27
|
+
"name": "John Doe",
|
|
28
|
+
"email": "john@example.com"
|
|
29
|
+
}
|
|
30
|
+
cache.set(url, response_data)
|
|
31
|
+
print(f" Key: {url}")
|
|
32
|
+
print(f" Value: {cache.get(url)}")
|
|
33
|
+
print()
|
|
34
|
+
|
|
35
|
+
# Example 2: Namespace with colons
|
|
36
|
+
print("2. Using namespace notation with colons:")
|
|
37
|
+
key = "app:config:database:host"
|
|
38
|
+
value = "localhost:5432"
|
|
39
|
+
cache.set(key, value)
|
|
40
|
+
print(f" Key: {key}")
|
|
41
|
+
print(f" Value: {cache.get(key)}")
|
|
42
|
+
print()
|
|
43
|
+
|
|
44
|
+
# Example 3: File paths as keys
|
|
45
|
+
print("3. Using file paths as keys:")
|
|
46
|
+
windows_path = "C:\\Users\\Admin\\Documents\\file.txt"
|
|
47
|
+
unix_path = "/home/user/documents/file.txt"
|
|
48
|
+
cache.set(windows_path, "Windows file content")
|
|
49
|
+
cache.set(unix_path, "Unix file content")
|
|
50
|
+
print(f" Windows path: {windows_path}")
|
|
51
|
+
print(f" Value: {cache.get(windows_path)}")
|
|
52
|
+
print(f" Unix path: {unix_path}")
|
|
53
|
+
print(f" Value: {cache.get(unix_path)}")
|
|
54
|
+
print()
|
|
55
|
+
|
|
56
|
+
# Example 4: Dot notation (config keys)
|
|
57
|
+
print("4. Using dot notation for configuration:")
|
|
58
|
+
config_keys = {
|
|
59
|
+
"app.name": "MyApp",
|
|
60
|
+
"app.version": "1.0.0",
|
|
61
|
+
"database.host": "localhost",
|
|
62
|
+
"database.port": 5432,
|
|
63
|
+
}
|
|
64
|
+
for key, value in config_keys.items():
|
|
65
|
+
cache.set(key, value)
|
|
66
|
+
print(f" {key} = {cache.get(key)}")
|
|
67
|
+
print()
|
|
68
|
+
|
|
69
|
+
# Example 5: Mixed special characters
|
|
70
|
+
print("5. Complex keys with multiple special characters:")
|
|
71
|
+
complex_keys = [
|
|
72
|
+
"user@domain.com:session:2024-01-01",
|
|
73
|
+
"file://server/share/path/to/file.txt",
|
|
74
|
+
"redis://localhost:6379/0",
|
|
75
|
+
]
|
|
76
|
+
for i, key in enumerate(complex_keys):
|
|
77
|
+
cache.set(key, f"value_{i}")
|
|
78
|
+
print(f" Key: {key}")
|
|
79
|
+
print(f" Value: {cache.get(key)}")
|
|
80
|
+
print()
|
|
81
|
+
|
|
82
|
+
# Example 6: Auto-deserialization
|
|
83
|
+
print("6. Auto-deserialization support:")
|
|
84
|
+
|
|
85
|
+
# Store Python objects (automatically pickled)
|
|
86
|
+
cache.set("python_dict", {"nested": {"data": [1, 2, 3]}})
|
|
87
|
+
print(f" Python dict: {cache.get('python_dict')}")
|
|
88
|
+
|
|
89
|
+
# Store JSON data (automatically detected and parsed)
|
|
90
|
+
import json
|
|
91
|
+
json_bytes = json.dumps({"type": "json", "value": 42}).encode('utf-8')
|
|
92
|
+
cache._cache.set("json_data", json_bytes, expire_time=None, tags=[])
|
|
93
|
+
print(f" JSON data: {cache.get('json_data')}")
|
|
94
|
+
|
|
95
|
+
# Store plain text (automatically decoded)
|
|
96
|
+
text_bytes = "Hello, World!".encode('utf-8')
|
|
97
|
+
cache._cache.set("text_data", text_bytes, expire_time=None, tags=[])
|
|
98
|
+
print(f" Text data: {cache.get('text_data')}")
|
|
99
|
+
print()
|
|
100
|
+
|
|
101
|
+
print("=" * 60)
|
|
102
|
+
print("All examples completed successfully!")
|
|
103
|
+
print("=" * 60)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
if __name__ == "__main__":
|
|
107
|
+
main()
|
|
@@ -4,6 +4,7 @@ Python-compatible cache interface for diskcache_rs
|
|
|
4
4
|
|
|
5
5
|
import functools
|
|
6
6
|
import hashlib
|
|
7
|
+
import json
|
|
7
8
|
import os
|
|
8
9
|
import threading
|
|
9
10
|
import time
|
|
@@ -136,6 +137,45 @@ class Cache:
|
|
|
136
137
|
except Exception:
|
|
137
138
|
return False
|
|
138
139
|
|
|
140
|
+
def _auto_deserialize(self, data: bytes) -> Any:
|
|
141
|
+
"""
|
|
142
|
+
Auto-detect and deserialize data from various formats
|
|
143
|
+
|
|
144
|
+
Tries to deserialize in the following order:
|
|
145
|
+
1. Pickle (most common for diskcache)
|
|
146
|
+
2. JSON (if data looks like JSON)
|
|
147
|
+
3. Raw bytes (if all else fails)
|
|
148
|
+
|
|
149
|
+
Args:
|
|
150
|
+
data: Serialized data bytes
|
|
151
|
+
|
|
152
|
+
Returns:
|
|
153
|
+
Deserialized value
|
|
154
|
+
"""
|
|
155
|
+
# Try pickle first (most common)
|
|
156
|
+
try:
|
|
157
|
+
return pickle.loads(data)
|
|
158
|
+
except Exception:
|
|
159
|
+
pass
|
|
160
|
+
|
|
161
|
+
# Try JSON if it looks like JSON
|
|
162
|
+
try:
|
|
163
|
+
# Check if data starts with common JSON markers
|
|
164
|
+
if data and data[0:1] in (b'{', b'[', b'"'):
|
|
165
|
+
text = data.decode('utf-8')
|
|
166
|
+
return json.loads(text)
|
|
167
|
+
except Exception:
|
|
168
|
+
pass
|
|
169
|
+
|
|
170
|
+
# Try plain text
|
|
171
|
+
try:
|
|
172
|
+
return data.decode('utf-8')
|
|
173
|
+
except Exception:
|
|
174
|
+
pass
|
|
175
|
+
|
|
176
|
+
# Return raw bytes as last resort
|
|
177
|
+
return data
|
|
178
|
+
|
|
139
179
|
def get(
|
|
140
180
|
self,
|
|
141
181
|
key: str,
|
|
@@ -164,8 +204,8 @@ class Cache:
|
|
|
164
204
|
if serialized_value is None:
|
|
165
205
|
return default
|
|
166
206
|
|
|
167
|
-
#
|
|
168
|
-
value =
|
|
207
|
+
# Auto-detect and deserialize the value
|
|
208
|
+
value = self._auto_deserialize(serialized_value)
|
|
169
209
|
|
|
170
210
|
# Handle additional return values
|
|
171
211
|
if expire_time or tag:
|
|
@@ -51,17 +51,19 @@ pub fn validate_key(key: &str) -> CacheResult<()> {
|
|
|
51
51
|
return Err(CacheError::InvalidConfig("Key cannot be empty".to_string()));
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
// Increased limit since we use hash-based filenames
|
|
55
|
+
// The actual key can be longer as it's not directly used as filename
|
|
56
|
+
if key.len() > 4096 {
|
|
55
57
|
return Err(CacheError::InvalidConfig(
|
|
56
|
-
"Key too long (max
|
|
58
|
+
"Key too long (max 4096 characters)".to_string(),
|
|
57
59
|
));
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
if key.
|
|
62
|
+
// Only check for null character which is truly invalid in all contexts
|
|
63
|
+
// Special characters like :, /, etc. are now allowed since we use hash-based filenames
|
|
64
|
+
if key.contains('\0') {
|
|
63
65
|
return Err(CacheError::InvalidConfig(
|
|
64
|
-
"Key contains
|
|
66
|
+
"Key contains null character".to_string(),
|
|
65
67
|
));
|
|
66
68
|
}
|
|
67
69
|
|
|
@@ -278,10 +280,20 @@ mod tests {
|
|
|
278
280
|
|
|
279
281
|
#[test]
|
|
280
282
|
fn test_validate_key() {
|
|
283
|
+
// Valid keys
|
|
281
284
|
assert!(validate_key("valid_key").is_ok());
|
|
282
|
-
assert!(validate_key("").
|
|
283
|
-
assert!(validate_key("key
|
|
284
|
-
assert!(validate_key(
|
|
285
|
+
assert!(validate_key("key/with/slash").is_ok()); // Now allowed
|
|
286
|
+
assert!(validate_key("key:with:colon").is_ok()); // Now allowed
|
|
287
|
+
assert!(validate_key("key\\with\\backslash").is_ok()); // Now allowed
|
|
288
|
+
assert!(validate_key("key.with.dot").is_ok()); // Dot is allowed
|
|
289
|
+
assert!(validate_key("config.app.settings").is_ok()); // Multiple dots
|
|
290
|
+
assert!(validate_key("file.name.txt").is_ok()); // File extensions
|
|
291
|
+
assert!(validate_key("http://example.com/path").is_ok()); // URLs
|
|
292
|
+
|
|
293
|
+
// Invalid keys
|
|
294
|
+
assert!(validate_key("").is_err()); // Empty key
|
|
295
|
+
assert!(validate_key("key\0with\0null").is_err()); // Null character
|
|
296
|
+
assert!(validate_key(&"x".repeat(5000)).is_err()); // Too long (>4096)
|
|
285
297
|
}
|
|
286
298
|
|
|
287
299
|
#[test]
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Test support for special characters in cache keys
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import pickle
|
|
7
|
+
import tempfile
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
import pytest
|
|
11
|
+
|
|
12
|
+
from diskcache_rs import Cache
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TestSpecialCharKeys:
|
|
16
|
+
"""Test cache with special characters in keys"""
|
|
17
|
+
|
|
18
|
+
def test_key_with_colon(self):
|
|
19
|
+
"""Test keys containing colon character"""
|
|
20
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
21
|
+
cache = Cache(tmpdir)
|
|
22
|
+
|
|
23
|
+
# Test with colon in key
|
|
24
|
+
key = "namespace:user:123"
|
|
25
|
+
value = {"user_id": 123, "name": "test"}
|
|
26
|
+
|
|
27
|
+
cache.set(key, value)
|
|
28
|
+
result = cache.get(key)
|
|
29
|
+
|
|
30
|
+
assert result == value
|
|
31
|
+
assert key in cache
|
|
32
|
+
|
|
33
|
+
def test_key_with_slash(self):
|
|
34
|
+
"""Test keys containing forward slash"""
|
|
35
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
36
|
+
cache = Cache(tmpdir)
|
|
37
|
+
|
|
38
|
+
# Test with slash in key
|
|
39
|
+
key = "path/to/resource"
|
|
40
|
+
value = "resource_data"
|
|
41
|
+
|
|
42
|
+
cache.set(key, value)
|
|
43
|
+
result = cache.get(key)
|
|
44
|
+
|
|
45
|
+
assert result == value
|
|
46
|
+
assert key in cache
|
|
47
|
+
|
|
48
|
+
def test_key_with_backslash(self):
|
|
49
|
+
"""Test keys containing backslash"""
|
|
50
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
51
|
+
cache = Cache(tmpdir)
|
|
52
|
+
|
|
53
|
+
# Test with backslash in key (Windows path style)
|
|
54
|
+
key = "C:\\Users\\test\\file.txt"
|
|
55
|
+
value = "file_content"
|
|
56
|
+
|
|
57
|
+
cache.set(key, value)
|
|
58
|
+
result = cache.get(key)
|
|
59
|
+
|
|
60
|
+
assert result == value
|
|
61
|
+
assert key in cache
|
|
62
|
+
|
|
63
|
+
def test_key_with_dot(self):
|
|
64
|
+
"""Test keys containing dot character"""
|
|
65
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
66
|
+
cache = Cache(tmpdir)
|
|
67
|
+
|
|
68
|
+
# Test with dot in key
|
|
69
|
+
key = "config.database.host"
|
|
70
|
+
value = "localhost"
|
|
71
|
+
|
|
72
|
+
cache.set(key, value)
|
|
73
|
+
result = cache.get(key)
|
|
74
|
+
|
|
75
|
+
assert result == value
|
|
76
|
+
assert key in cache
|
|
77
|
+
|
|
78
|
+
def test_key_with_multiple_special_chars(self):
|
|
79
|
+
"""Test keys with multiple special characters"""
|
|
80
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
81
|
+
cache = Cache(tmpdir)
|
|
82
|
+
|
|
83
|
+
# Test with multiple special characters
|
|
84
|
+
test_keys = [
|
|
85
|
+
"http://example.com/path?query=1",
|
|
86
|
+
"user@domain.com:password",
|
|
87
|
+
"file://C:\\path\\to\\file",
|
|
88
|
+
"key:with:many:colons",
|
|
89
|
+
"path/with/many/slashes",
|
|
90
|
+
"mixed:path/with\\all",
|
|
91
|
+
"config.app.settings", # dot notation
|
|
92
|
+
"file.name.with.dots.txt", # multiple dots
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
for i, key in enumerate(test_keys):
|
|
96
|
+
value = f"value_{i}"
|
|
97
|
+
cache.set(key, value)
|
|
98
|
+
result = cache.get(key)
|
|
99
|
+
assert result == value, f"Failed for key: {key}"
|
|
100
|
+
assert key in cache
|
|
101
|
+
|
|
102
|
+
def test_url_as_key(self):
|
|
103
|
+
"""Test using URLs as cache keys"""
|
|
104
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
105
|
+
cache = Cache(tmpdir)
|
|
106
|
+
|
|
107
|
+
# Test with full URL
|
|
108
|
+
url = "https://api.example.com/v1/users/123?include=profile&format=json"
|
|
109
|
+
response_data = {
|
|
110
|
+
"user_id": 123,
|
|
111
|
+
"name": "John Doe",
|
|
112
|
+
"email": "john@example.com"
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
cache.set(url, response_data)
|
|
116
|
+
result = cache.get(url)
|
|
117
|
+
|
|
118
|
+
assert result == response_data
|
|
119
|
+
assert url in cache
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
class TestAutoDeserialization:
|
|
123
|
+
"""Test automatic deserialization of different formats"""
|
|
124
|
+
|
|
125
|
+
def test_pickle_deserialization(self):
|
|
126
|
+
"""Test automatic pickle deserialization"""
|
|
127
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
128
|
+
cache = Cache(tmpdir)
|
|
129
|
+
|
|
130
|
+
# Store complex Python object
|
|
131
|
+
value = {"list": [1, 2, 3], "dict": {"nested": True}, "tuple": (1, 2)}
|
|
132
|
+
cache.set("test_key", value)
|
|
133
|
+
result = cache.get("test_key")
|
|
134
|
+
|
|
135
|
+
assert result == value
|
|
136
|
+
|
|
137
|
+
def test_json_deserialization(self):
|
|
138
|
+
"""Test automatic JSON deserialization"""
|
|
139
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
140
|
+
cache = Cache(tmpdir)
|
|
141
|
+
|
|
142
|
+
# Manually store JSON data
|
|
143
|
+
json_data = {"key": "value", "number": 42}
|
|
144
|
+
json_bytes = json.dumps(json_data).encode('utf-8')
|
|
145
|
+
|
|
146
|
+
# Use internal Rust cache to store raw JSON
|
|
147
|
+
cache._cache.set("json_key", json_bytes, expire_time=None, tags=[])
|
|
148
|
+
|
|
149
|
+
# Should auto-deserialize JSON
|
|
150
|
+
result = cache.get("json_key")
|
|
151
|
+
assert result == json_data
|
|
152
|
+
|
|
153
|
+
def test_text_deserialization(self):
|
|
154
|
+
"""Test automatic text deserialization"""
|
|
155
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
156
|
+
cache = Cache(tmpdir)
|
|
157
|
+
|
|
158
|
+
# Store plain text
|
|
159
|
+
text = "Hello, World!"
|
|
160
|
+
text_bytes = text.encode('utf-8')
|
|
161
|
+
|
|
162
|
+
# Use internal Rust cache to store raw text
|
|
163
|
+
cache._cache.set("text_key", text_bytes, expire_time=None, tags=[])
|
|
164
|
+
|
|
165
|
+
# Should auto-deserialize to text
|
|
166
|
+
result = cache.get("text_key")
|
|
167
|
+
assert result == text
|
|
168
|
+
|
|
169
|
+
def test_mixed_formats(self):
|
|
170
|
+
"""Test cache with mixed serialization formats"""
|
|
171
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
172
|
+
cache = Cache(tmpdir)
|
|
173
|
+
|
|
174
|
+
# Store different formats
|
|
175
|
+
cache.set("pickle_key", {"type": "pickle"})
|
|
176
|
+
cache._cache.set("json_key", b'{"type": "json"}', expire_time=None, tags=[])
|
|
177
|
+
cache._cache.set("text_key", b"plain text", expire_time=None, tags=[])
|
|
178
|
+
|
|
179
|
+
# All should deserialize correctly
|
|
180
|
+
assert cache.get("pickle_key") == {"type": "pickle"}
|
|
181
|
+
assert cache.get("json_key") == {"type": "json"}
|
|
182
|
+
assert cache.get("text_key") == "plain text"
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|