diskcache-rs 0.4.2__tar.gz → 0.4.4__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 (82) hide show
  1. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/.github/actions/build-and-test/action.yml +2 -2
  2. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/.github/actions/setup-diskcache-rs/action.yml +1 -1
  3. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/.github/workflows/ci.yml +3 -3
  4. diskcache_rs-0.4.4/.release-please-manifest.json +3 -0
  5. diskcache_rs-0.4.4/API_COMPATIBILITY.md +333 -0
  6. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/CHANGELOG.md +32 -0
  7. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/Cargo.lock +1 -1
  8. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/Cargo.toml +1 -1
  9. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/PKG-INFO +1 -1
  10. diskcache_rs-0.4.4/examples/special_chars_keys_example.py +107 -0
  11. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/python/diskcache_rs/__init__.py +2 -12
  12. diskcache_rs-0.4.4/python/diskcache_rs/cache.py +1135 -0
  13. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/src/lib.rs +3 -0
  14. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/src/storage/optimized_backend.rs +149 -0
  15. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/src/utils.rs +21 -9
  16. diskcache_rs-0.4.4/tests/test_api_compatibility.py +538 -0
  17. diskcache_rs-0.4.4/tests/test_diskcache_rs_persistence_suite.py +238 -0
  18. diskcache_rs-0.4.4/tests/test_special_chars_keys.py +182 -0
  19. diskcache_rs-0.4.2/.release-please-manifest.json +0 -3
  20. diskcache_rs-0.4.2/python/diskcache_rs/cache.py +0 -576
  21. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  22. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  23. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/.github/pull_request_template.md +0 -0
  24. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/.github/workflows/benchmark.yml +0 -0
  25. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/.github/workflows/build-abi3.yml +0 -0
  26. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/.github/workflows/build.yml +0 -0
  27. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/.github/workflows/release.yml +0 -0
  28. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/.gitignore +0 -0
  29. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/.pre-commit-config.yaml +0 -0
  30. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/Dockerfile.test +0 -0
  31. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/LICENSE +0 -0
  32. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/README.md +0 -0
  33. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/benchmarks/comprehensive_performance_test.py +0 -0
  34. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/benchmarks/detailed_profiling.py +0 -0
  35. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/benchmarks/final_performance_comparison.py +0 -0
  36. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/benchmarks/high_performance_test.py +0 -0
  37. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/benchmarks/memory_usage_test.py +0 -0
  38. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/benchmarks/micro_benchmark.py +0 -0
  39. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/benchmarks/optimization_validation_test.py +0 -0
  40. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/benchmarks/performance_comparison.py +0 -0
  41. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/benchmarks/precise_benchmark.py +0 -0
  42. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/benchmarks/set_performance_analysis.py +0 -0
  43. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/docker-compose.test.yml +0 -0
  44. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/examples/basic_usage.py +0 -0
  45. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/justfile +0 -0
  46. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/pyproject.toml +0 -0
  47. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/python/diskcache_rs/__init__.pyi +0 -0
  48. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/python/diskcache_rs/_diskcache_rs.pyi +0 -0
  49. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/python/diskcache_rs/core.py +0 -0
  50. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/python/diskcache_rs/fast_cache.py +0 -0
  51. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/python/diskcache_rs/pickle_cache.py +0 -0
  52. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/python/diskcache_rs/rust_pickle.py +0 -0
  53. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/release-please-config.json +0 -0
  54. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/renovate.json +0 -0
  55. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/scripts/generate_stubs.py +0 -0
  56. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/scripts/sync_version.py +0 -0
  57. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/scripts/test-docker-network.sh +0 -0
  58. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/src/cache.rs +0 -0
  59. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/src/error.rs +0 -0
  60. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/src/eviction.rs +0 -0
  61. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/src/memory_cache.rs +0 -0
  62. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/src/migration.rs +0 -0
  63. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/src/pickle_cache.rs +0 -0
  64. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/src/serialization.rs +0 -0
  65. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/src/storage/tests.rs +0 -0
  66. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/src/storage.rs +0 -0
  67. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/tests/__init__.py +0 -0
  68. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/tests/benchmark_official.py +0 -0
  69. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/tests/conftest.py +0 -0
  70. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/tests/test_basic_operations.py +0 -0
  71. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/tests/test_ci_benchmark.py +0 -0
  72. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/tests/test_compatibility.py +0 -0
  73. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/tests/test_cross_platform_network.py +0 -0
  74. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/tests/test_docker_network.py +0 -0
  75. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/tests/test_fast_cache.py +0 -0
  76. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/tests/test_issue_17_configurable_threshold.py +0 -0
  77. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/tests/test_network_filesystem.py +0 -0
  78. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/tests/test_performance.py +0 -0
  79. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/tests/test_pickle_cache.py +0 -0
  80. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/tests/test_rust_pickle_performance.py +0 -0
  81. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/tests/test_version_and_disk_threshold.py +0 -0
  82. {diskcache_rs-0.4.2 → diskcache_rs-0.4.4}/uv.lock +0 -0
@@ -32,7 +32,7 @@ runs:
32
32
  shell: bash
33
33
  run: |
34
34
  uv run pyo3-stubgen diskcache_rs._diskcache_rs python/diskcache_rs/
35
- echo "✅ Type stubs generated successfully"
35
+ echo "Type stubs generated successfully"
36
36
 
37
37
  - name: Run basic tests
38
38
  if: inputs.test-type == 'basic'
@@ -51,7 +51,7 @@ runs:
51
51
  - name: Verify import
52
52
  shell: bash
53
53
  run: |
54
- uv run python -c 'import diskcache_rs; print(f"✅ diskcache_rs v{diskcache_rs.__version__} imported successfully")'
54
+ uv run python -c 'import diskcache_rs; print(f"diskcache_rs v{diskcache_rs.__version__} imported successfully")'
55
55
 
56
56
  - name: Upload test artifacts
57
57
  if: inputs.upload-artifacts == 'true' && always()
@@ -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('**/Cargo.lock') }}
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-
@@ -100,11 +100,11 @@ jobs:
100
100
  - name: Check all required jobs
101
101
  run: |
102
102
  if [[ "${{ needs.quick-test.result }}" != "success" ]]; then
103
- echo "❌ Quick tests failed"
103
+ echo "ERROR: Quick tests failed"
104
104
  exit 1
105
105
  fi
106
106
  if [[ "${{ needs.lint.result }}" != "success" ]]; then
107
- echo "❌ Linting failed"
107
+ echo "ERROR: Linting failed"
108
108
  exit 1
109
109
  fi
110
- echo "✅ All required CI checks passed"
110
+ echo "SUCCESS: All required CI checks passed"
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.4.4"
3
+ }
@@ -0,0 +1,333 @@
1
+ # diskcache_rs API Compatibility Report
2
+
3
+ ## Executive Summary
4
+
5
+ **Question**: Can developers simply change the namespace from `diskcache` to `diskcache_rs` for a drop-in replacement?
6
+
7
+ **Answer**: ✅ **~95% Compatible (v0.4.3+)** - Core operations, atomic operations, memoization, transactions, and iteration fully compatible. Only advanced features like tags and queues remain unimplemented.
8
+
9
+ ---
10
+
11
+ ## Cache Class API Comparison
12
+
13
+ ### ✅ Fully Compatible Methods (Core API)
14
+
15
+ | Method | diskcache | diskcache_rs | Notes |
16
+ |--------|-----------|--------------|-------|
17
+ | `__init__(directory, timeout, ...)` | ✅ | ✅ | Compatible |
18
+ | `__contains__(key)` | ✅ | ✅ | Compatible |
19
+ | `__getitem__(key)` | ✅ | ✅ | Compatible |
20
+ | `__setitem__(key, value)` | ✅ | ✅ | Compatible |
21
+ | `__delitem__(key)` | ✅ | ✅ | Compatible |
22
+ | `__iter__()` | ✅ | ✅ | Compatible |
23
+ | `__len__()` | ✅ | ✅ | Compatible |
24
+ | `get(key, default, ...)` | ✅ | ✅ | Compatible |
25
+ | `set(key, value, expire, ...)` | ✅ | ✅ | Compatible |
26
+ | `delete(key, retry)` | ✅ | ✅ | Compatible |
27
+ | `add(key, value, expire, ...)` | ✅ | ✅ | Compatible |
28
+ | `pop(key, default, ...)` | ✅ | ✅ | Compatible |
29
+ | `clear(retry)` | ✅ | ✅ | Compatible |
30
+ | `incr(key, delta, default)` | ✅ | ✅ | Compatible |
31
+ | `decr(key, delta, default)` | ✅ | ✅ | Compatible |
32
+ | `touch(key, expire)` | ✅ | ✅ | Compatible |
33
+ | `stats(enable, reset)` | ✅ | ✅ | Compatible |
34
+ | `volume()` | ✅ | ✅ | Compatible |
35
+ | `close()` | ✅ | ✅ | Compatible |
36
+ | `__enter__()` / `__exit__()` | ✅ | ✅ | Context manager support |
37
+ | `memoize(name, typed, expire, tag, ignore)` | ✅ | ✅ | Compatible (v0.4.3+) |
38
+ | `transact(retry)` | ✅ | ✅ | Compatible (v0.4.3+) |
39
+ | `iterkeys(reverse)` | ✅ | ✅ | Compatible (v0.4.3+) |
40
+ | `__reversed__()` | ✅ | ✅ | Compatible (v0.4.3+) |
41
+ | `peekitem(last, expire_time, tag, retry)` | ✅ | ✅ | Compatible (v0.4.3+) |
42
+ | `directory` (property) | ✅ | ✅ | Compatible (v0.4.3+) |
43
+ | `timeout` (property) | ✅ | ✅ | Compatible (v0.4.3+) |
44
+
45
+ ### ⚠️ Partially Compatible Methods
46
+
47
+ | Method | diskcache | diskcache_rs | Status | Notes |
48
+ |--------|-----------|--------------|--------|-------|
49
+ | `get(..., expire_time=True)` | ✅ | ⚠️ | Returns None | Not implemented |
50
+ | `get(..., tag=True)` | ✅ | ⚠️ | Returns None | Not implemented |
51
+ | `get(..., read=True)` | ✅ | ⚠️ | Ignored | File handle not supported |
52
+ | `set(..., read=True)` | ✅ | ⚠️ | Ignored | File handle not supported |
53
+ | `set(..., tag=...)` | ✅ | ⚠️ | Ignored | Tag not stored |
54
+
55
+ ### ❌ Missing Methods (Advanced Features)
56
+
57
+ | Method | diskcache | diskcache_rs | Impact |
58
+ |--------|-----------|--------------|--------|
59
+ | `check(fix, retry)` | ✅ | ❌ | Medium - debugging tool |
60
+ | `create_tag_index()` | ✅ | ❌ | Low - tag feature not supported |
61
+ | `drop_tag_index()` | ✅ | ❌ | Low - tag feature not supported |
62
+ | `cull(retry)` | ✅ | ❌ | Medium - eviction policy |
63
+ | `evict(tag, retry)` | ✅ | ❌ | Low - tag feature not supported |
64
+ | `expire(now, retry)` | ✅ | ❌ | Medium - manual expiration |
65
+ | `peek(prefix, ...)` | ✅ | ❌ | Medium - queue operations |
66
+ | `pull(prefix, ...)` | ✅ | ❌ | Medium - queue operations |
67
+ | `push(value, prefix, ...)` | ✅ | ❌ | Medium - queue operations |
68
+ | `read(key, retry)` | ✅ | ❌ | Low - file handle feature |
69
+ | `reset(key, value, ...)` | ✅ | ❌ | Low - settings management |
70
+ | `disk` (property) | ✅ | ❌ | Low - internal detail |
71
+
72
+ ---
73
+
74
+ ## FanoutCache Class API Comparison
75
+
76
+ ### ✅ Fully Compatible Methods
77
+
78
+ | Method | diskcache | diskcache_rs | Notes |
79
+ |--------|-----------|--------------|-------|
80
+ | `__init__(directory, shards, ...)` | ✅ | ✅ | Compatible |
81
+ | `__contains__(key)` | ✅ | ✅ | Compatible |
82
+ | `__getitem__(key)` | ✅ | ✅ | Compatible |
83
+ | `__setitem__(key, value)` | ✅ | ✅ | Compatible |
84
+ | `__delitem__(key)` | ✅ | ✅ | Compatible |
85
+ | `__iter__()` | ✅ | ✅ | Compatible |
86
+ | `__len__()` | ✅ | ✅ | Compatible |
87
+ | `get(key, default, ...)` | ✅ | ✅ | Compatible |
88
+ | `set(key, value, expire, ...)` | ✅ | ✅ | Compatible |
89
+ | `delete(key, retry)` | ✅ | ✅ | Compatible |
90
+ | `clear(retry)` | ✅ | ✅ | Compatible |
91
+ | `stats(enable, reset)` | ✅ | ✅ | Compatible |
92
+ | `volume()` | ✅ | ✅ | Compatible |
93
+ | `close()` | ✅ | ✅ | Compatible |
94
+ | `__enter__()` / `__exit__()` | ✅ | ✅ | Context manager support |
95
+
96
+ ### ✅ Newly Added Methods (FanoutCache) - v0.4.2+
97
+
98
+ | Method | diskcache | diskcache_rs | Status |
99
+ |--------|-----------|--------------|--------|
100
+ | `add(key, value, ...)` | ✅ | ✅ | **NEW** - Atomic add |
101
+ | `incr(key, delta, ...)` | ✅ | ✅ | **NEW** - Increment |
102
+ | `decr(key, delta, ...)` | ✅ | ✅ | **NEW** - Decrement |
103
+ | `pop(key, default, ...)` | ✅ | ✅ | **NEW** - Atomic pop |
104
+ | `touch(key, expire, ...)` | ✅ | ✅ | **NEW** - Update expiration |
105
+
106
+ ### ❌ Missing Methods (FanoutCache)
107
+
108
+ | Method | diskcache | diskcache_rs | Impact |
109
+ |--------|-----------|--------------|--------|
110
+ | `__reversed__()` | ✅ | ❌ | Low |
111
+ | `check(fix, retry)` | ✅ | ❌ | Medium |
112
+ | `create_tag_index()` | ✅ | ❌ | Low |
113
+ | `drop_tag_index()` | ✅ | ❌ | Low |
114
+ | `cull(retry)` | ✅ | ❌ | Medium |
115
+ | `evict(tag, retry)` | ✅ | ❌ | Low |
116
+ | `expire(retry)` | ✅ | ❌ | Medium |
117
+ | `memoize(...)` | ✅ | ❌ | **High** |
118
+ | `read(key)` | ✅ | ❌ | Low |
119
+ | `reset(key, value)` | ✅ | ❌ | Low |
120
+ | `transact(retry)` | ✅ | ❌ | **High** |
121
+ | `cache(name, ...)` | ✅ | ❌ | Medium - sub-cache |
122
+ | `deque(name, ...)` | ✅ | ❌ | Medium - deque support |
123
+ | `index(name)` | ✅ | ❌ | Medium - index support |
124
+ | `directory` (property) | ✅ | ❌ | Low |
125
+
126
+ ---
127
+
128
+ ## Migration Impact Assessment
129
+
130
+ ### ✅ **Low-Risk Migration** (Simple Use Cases)
131
+
132
+ If your code only uses:
133
+ - Basic get/set/delete operations
134
+ - Dictionary-style access (`cache[key]`, `key in cache`)
135
+ - Iteration and length
136
+ - Context managers (`with cache:`)
137
+ - Basic statistics
138
+
139
+ **Migration**: Simply change `import diskcache` to `import diskcache_rs` ✅
140
+
141
+ ### ✅ **Medium-Risk Migration** (Advanced Features) - NOW SUPPORTED
142
+
143
+ If your code uses:
144
+ - `incr()`/`decr()` operations
145
+ - `add()` for atomic operations
146
+ - `touch()` to update expiration
147
+ - `pop()` to atomically remove and return
148
+
149
+ **Migration**:
150
+ - `Cache` class: ✅ Fully supported
151
+ - `FanoutCache` class: ✅ **NOW FULLY SUPPORTED** (v0.4.2+)
152
+
153
+ ⚠️ Still missing:
154
+ - Queue operations (`push`/`pull`/`peek`) - Not implemented
155
+
156
+ ### ❌ **High-Risk Migration** (Breaking Changes)
157
+
158
+ If your code uses:
159
+ - **`memoize()` decorator** - Not implemented
160
+ - **`transact()` context manager** - Not implemented
161
+ - **Tag-based operations** (`evict(tag)`, tag indexes) - Not implemented
162
+ - **File handle operations** (`read=True` parameter) - Not implemented
163
+ - **Queue operations** (`push`/`pull`/`peek`) - Not implemented
164
+ - **Sub-caches** (`cache.cache(name)`, `cache.deque(name)`, `cache.index(name)`) - Not implemented
165
+
166
+ **Migration**: ❌ Requires code refactoring or feature implementation
167
+
168
+ ---
169
+
170
+ ## Recommendations
171
+
172
+ ### For Drop-in Replacement Compatibility
173
+
174
+ To achieve true drop-in replacement, implement these **high-priority** missing methods:
175
+
176
+ #### Cache Class (Priority Order)
177
+
178
+ 1. **Critical** (Widely Used):
179
+ - `memoize()` - Decorator for function memoization
180
+ - `transact()` - Transaction context manager
181
+
182
+ 2. **High** (Common Use Cases):
183
+ - `add()` for FanoutCache - Atomic add operation
184
+ - `incr()`/`decr()` for FanoutCache - Counter operations
185
+ - `pop()` for FanoutCache - Atomic pop operation
186
+ - `touch()` for FanoutCache - Update expiration
187
+
188
+ 3. **Medium** (Nice to Have):
189
+ - `expire()` - Manual expiration cleanup
190
+ - `cull()` - Manual eviction
191
+ - `push()`/`pull()`/`peek()` - Queue operations
192
+ - `directory`, `timeout` properties - Metadata access
193
+
194
+ 4. **Low** (Rarely Used):
195
+ - `__reversed__()` - Reverse iteration
196
+ - `iterkeys()` - Alternative iteration
197
+ - `check()` - Consistency checking
198
+ - Tag-based features - Tag indexing and eviction
199
+
200
+ ### Current Compatibility Score (v0.4.2+)
201
+
202
+ | Category | Score | Details |
203
+ |----------|-------|---------|
204
+ | **Core Operations** | 100% | ✅ get, set, delete, clear, contains, iteration |
205
+ | **Dictionary Interface** | 100% | ✅ `[]`, `in`, `len()`, `iter()` |
206
+ | **Atomic Operations** | 100% | ✅ Cache & FanoutCache: incr/decr/add/pop/touch |
207
+ | **Advanced Features** | 20% | ❌ memoize, transact, tags, queues |
208
+ | **Overall** | **80%** | ⬆️ **+10%** - Excellent for most use cases |
209
+
210
+ ---
211
+
212
+ ## Example Migration Scenarios
213
+
214
+ ### ✅ Scenario 1: Simple Cache (Works Out of Box)
215
+
216
+ ```python
217
+ # Before (diskcache)
218
+ from diskcache import Cache
219
+
220
+ cache = Cache('/tmp/mycache')
221
+ cache['key'] = 'value'
222
+ print(cache['key'])
223
+ del cache['key']
224
+
225
+ # After (diskcache_rs) - NO CHANGES NEEDED
226
+ from diskcache_rs import Cache
227
+
228
+ cache = Cache('/tmp/mycache')
229
+ cache['key'] = 'value'
230
+ print(cache['key'])
231
+ del cache['key']
232
+ ```
233
+
234
+ ### ✅ Scenario 2: Counter Operations (Works for Cache)
235
+
236
+ ```python
237
+ # Before (diskcache)
238
+ from diskcache import Cache
239
+
240
+ cache = Cache('/tmp/mycache')
241
+ cache.incr('counter', 1)
242
+ cache.decr('counter', 1)
243
+
244
+ # After (diskcache_rs) - NO CHANGES NEEDED
245
+ from diskcache_rs import Cache
246
+
247
+ cache = Cache('/tmp/mycache')
248
+ cache.incr('counter', 1)
249
+ cache.decr('counter', 1)
250
+ ```
251
+
252
+ ### ✅ Scenario 3: FanoutCache Counters (NOW WORKS - v0.4.2+)
253
+
254
+ ```python
255
+ # Before (diskcache)
256
+ from diskcache import FanoutCache
257
+
258
+ cache = FanoutCache('/tmp/mycache')
259
+ cache.incr('counter', 1) # ✅ Works
260
+
261
+ # After (diskcache_rs) - NOW WORKS!
262
+ from diskcache_rs import FanoutCache
263
+
264
+ cache = FanoutCache('/tmp/mycache')
265
+ cache.incr('counter', 1) # ✅ Works (v0.4.2+)
266
+ cache.decr('counter', 1) # ✅ Works (v0.4.2+)
267
+ cache.add('key', 'value') # ✅ Works (v0.4.2+)
268
+ cache.pop('key') # ✅ Works (v0.4.2+)
269
+ cache.touch('key', expire=60) # ✅ Works (v0.4.2+)
270
+ ```
271
+
272
+ ### ❌ Scenario 4: Memoization (Not Supported)
273
+
274
+ ```python
275
+ # Before (diskcache)
276
+ from diskcache import Cache
277
+
278
+ cache = Cache('/tmp/mycache')
279
+
280
+ @cache.memoize()
281
+ def expensive_function(x):
282
+ return x * x
283
+
284
+ # After (diskcache_rs) - NOT SUPPORTED
285
+ from diskcache_rs import Cache
286
+
287
+ cache = Cache('/tmp/mycache')
288
+
289
+ @cache.memoize() # ❌ AttributeError: 'Cache' object has no attribute 'memoize'
290
+ def expensive_function(x):
291
+ return x * x
292
+ ```
293
+
294
+ ---
295
+
296
+ ## Conclusion
297
+
298
+ ### Can developers just change the namespace?
299
+
300
+ **Answer**: **Yes, for 80% of use cases** ✅ (v0.4.2+)
301
+
302
+ - ✅ **Basic caching** (get/set/delete): Fully compatible
303
+ - ✅ **Dictionary interface**: Fully compatible
304
+ - ✅ **Atomic operations** (incr/decr/add/pop/touch): **Fully compatible** (Cache & FanoutCache)
305
+ - ✅ **Expiration management** (expire, touch): Fully compatible
306
+ - ✅ **Statistics & monitoring** (stats, volume): Fully compatible
307
+ - ❌ **Decorators & transactions**: Not supported, requires refactoring
308
+ - ❌ **Tag-based operations**: Not supported
309
+ - ❌ **Queue operations**: Not supported
310
+
311
+ ### Recommended Next Steps
312
+
313
+ 1. ✅ ~~**Implement FanoutCache missing methods**~~ - **DONE in v0.4.2**
314
+ 2. **Implement `memoize()` decorator** - High-value feature for users
315
+ 3. **Implement `transact()` context manager** - Important for atomic operations
316
+ 4. **Document incompatibilities** - Clear migration guide for users
317
+ 5. **Add compatibility layer** - Optional wrapper for 100% compatibility
318
+
319
+ ### Final Verdict (Updated for v0.4.2)
320
+
321
+ **diskcache_rs is now an excellent drop-in replacement for most use cases (80% compatibility)**, including:
322
+ - ✅ All basic caching operations
323
+ - ✅ All atomic operations (incr/decr/add/pop/touch)
324
+ - ✅ Both Cache and FanoutCache classes
325
+ - ✅ Context manager support
326
+ - ✅ Statistics and monitoring
327
+
328
+ Users relying on advanced features (memoization, transactions, tags, queues) will need to either:
329
+ - Wait for feature implementation
330
+ - Refactor their code
331
+ - Use a compatibility wrapper
332
+
333
+ **Migration is straightforward for 80% of use cases - just change the import!** 🎉
@@ -4,6 +4,38 @@
4
4
 
5
5
  - sync Cargo.toml version with .cz.toml and update CHANGELOG for v0.4.0
6
6
 
7
+ ## [0.4.4](https://github.com/loonghao/diskcache_rs/compare/diskcache_rs-v0.4.3...diskcache_rs-v0.4.4) (2025-11-22)
8
+
9
+
10
+ ### Features
11
+
12
+ * support special characters in cache keys and auto-deserialization ([e56ad93](https://github.com/loonghao/diskcache_rs/commit/e56ad939b1c95456929d46887441c8d8610f1476))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * resolve hashFiles path issue in GitHub Actions for macOS ([08abc64](https://github.com/loonghao/diskcache_rs/commit/08abc6442b2c7208b26038f28be07ab31dbccbe7))
18
+
19
+ ## [0.4.3](https://github.com/loonghao/diskcache_rs/compare/diskcache_rs-v0.4.2...diskcache_rs-v0.4.3) (2025-11-22)
20
+
21
+
22
+ ### Features
23
+
24
+ * implement advanced diskcache features (memoize, transact, iterkeys, peekitem) ([e11747d](https://github.com/loonghao/diskcache_rs/commit/e11747d5d6368e4ac96c850bb1ad748c0a87ec4a))
25
+ * improve API compatibility with python-diskcache ([b2b32fc](https://github.com/loonghao/diskcache_rs/commit/b2b32fc2918baa2593a75e7c6158487bfabb3e44))
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * critical persistence bug and improve version detection ([7de8f23](https://github.com/loonghao/diskcache_rs/commit/7de8f2361f9e6f47bc632dde9c6ab91f0716eb68))
31
+ * improve version fallback to read from Cargo.toml in development mode ([2aa633c](https://github.com/loonghao/diskcache_rs/commit/2aa633c6bd43b80216f2c8758fb21c88fb5ca984))
32
+ * remove emoji characters to fix Windows encoding issue ([59fda00](https://github.com/loonghao/diskcache_rs/commit/59fda00c3c213a2d020eb0210ae7a8fbd782ab76))
33
+
34
+
35
+ ### Code Refactoring
36
+
37
+ * simplify version detection logic ([ab60b25](https://github.com/loonghao/diskcache_rs/commit/ab60b250b05f1e3e9ab9fcb730a48805eda4f46f))
38
+
7
39
  ## [0.4.2](https://github.com/loonghao/diskcache_rs/compare/diskcache_rs-v0.4.1...diskcache_rs-v0.4.2) (2025-11-22)
8
40
 
9
41
 
@@ -236,7 +236,7 @@ dependencies = [
236
236
 
237
237
  [[package]]
238
238
  name = "diskcache_rs"
239
- version = "0.4.2"
239
+ version = "0.4.4"
240
240
  dependencies = [
241
241
  "anyhow",
242
242
  "bincode",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "diskcache_rs"
3
- version = "0.4.2"
3
+ version = "0.4.4"
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"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: diskcache_rs
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: Apache Software License
@@ -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()
@@ -18,18 +18,8 @@ except ImportError:
18
18
  rust_pickle_dumps = None
19
19
  rust_pickle_loads = None
20
20
 
21
- # Version is managed by maturin and synced from Cargo.toml
22
- try:
23
- from importlib.metadata import version, PackageNotFoundError
24
- except ImportError:
25
- # Python 3.7 fallback
26
- from importlib_metadata import version, PackageNotFoundError # type: ignore
27
-
28
- try:
29
- __version__ = version("diskcache_rs")
30
- except PackageNotFoundError:
31
- # Development mode fallback
32
- __version__ = "0.0.0-dev"
21
+ # Version is exported from Rust core module
22
+ from ._diskcache_rs import __version__
33
23
  __all__ = [
34
24
  "Cache",
35
25
  "FanoutCache",