Commit 3a0790c
committed
feat!: macro attrs, trait refinements, redis TLS split, store APIs (next major)
Next-major batch (after the redb DiskCache rewrite). Bundles a set of
breaking and additive changes plus the doc/test follow-ups.
Macros:
- `ttl_millis` attribute for sub-second TTLs, mutually exclusive with `ttl` (#149);
rejected alongside a `create` block like the other store-builder attributes
- `force_refresh` attribute to bypass the cache per call, on all three macros
(`#[cached]` / `#[concurrent_cached]` / `#[once]`); on `#[once]` it overwrites
the single shared value (no per-call key, so no key-exclusion caveat). Combined
with `result_fallback`, a force-refreshed `Err` still serves the previously
cached `Ok`, and capturing that fallback leaves no read side effects on the
bypassed entry (no TTL renewal, recency update, or hit-counter change) on both
`#[cached]` and `#[concurrent_cached]` (#146)
- `in_impl` attribute to cache methods inside `impl` blocks; `self`-receiver
methods require `in_impl` (a `convert` block alone cannot rescue them, since the
cache static cannot live at `impl` scope) and emit a `{fn}_no_cache`
cache-bypass sibling, hidden from rustdoc via `#[doc(hidden)]` (#16, #140)
- reference arguments (`&T`, `Option<&T>`) form the default key without `convert` (#202, #203)
- generated code resolves the crate path via `proc-macro-crate`, so a renamed or
re-exported `cached` dependency works (#157)
- macro-introduced bindings are hygienically named, so arguments named `key` /
`cache` / `result` no longer collide with generated code (#230, #114)
- clear compile error for generic functions used without `key` + `convert` (#80)
- the shared `force_refresh` guard builder is factored into one helper
Traits and stores:
- `get_or_set_with` / `try_get_or_set_with` (and the async variants) now return
`&V` instead of `&mut V`, with new `*_mut` variants preserving the old behavior (#179)
- new additive `SerializeCached` / `SerializeCachedAsync` traits (`cache_set_ref`)
for serialize-backed stores; `#[concurrent_cached]` routes its set through an
autoref shim that uses the borrowed setter for any store implementing the trait
(built-in redis/disk or a custom `ty`/`create` store), avoiding a value clone (#196, #195)
- `RedisCache` / `AsyncRedisCache` gain `cache_clear` / `async_cache_clear`, with
`cache_reset` delegating to `cache_clear`; `RedisCacheBuilder` /
`AsyncRedisCacheBuilder` `build()` reject an empty namespace+prefix scope
(`EmptyScope`) so `cache_clear` cannot `SCAN MATCH *` the whole database (#200)
- `RedbCacheBuilder::build()` validates `cache_name` as a filename component,
returning `InvalidCacheName` for a path separator (`/` or `\`) or a
path-traversal component (`.` / `..`)
- `LruCache::set_max_size` / `try_set_max_size` for resizing a live cache, with
matching methods on `LruTtlCache` and `ExpiringLruCache` (#180)
- `ConcurrentCloneCached` gains a non-renewing `cache_peek_with_expiry_status`
(used to capture a `result_fallback` stale value without read side effects)
Redis:
- TLS features split so rustls is selectable; `redis_tokio` / `redis_smol` no
longer imply native-tls (add `*_native_tls` or `*_rustls`) (#231)
Docs and process:
- document floats as the canonical `convert` case (#78); add cache-invalidation
and struct-method examples (#21, #236), the latter demonstrating `in_impl`
- release workflow tags and creates a GitHub release for each published workspace
crate on publish, via `bin/tag-release.sh` (root `cached` -> `vX.Y.Z`, subcrates
-> `<crate-name>-vX.Y.Z`) (#245); the CI tag-release git identity is scoped to `--local`
- fix a doctest under `--no-default-features` (#260)
- exclude internal dev tooling (.agents, .claude, .github, bin, docs/dev, AGENTS.md,
CLAUDE.md) from the published crate via Cargo `exclude`
- dev tooling: pr-review shards reviewers across model-sized, randomized chunks
(multiple of each type); pr-cycle fans fix application across disjoint sub-agents;
AGENTS.md states README is generated from src/lib.rs via cargo-readme
- documentation accuracy pass: `ttl_millis` is valid with `result_fallback` and (on the
in-memory path) needs `time_stores`; on `#[cached]` the "honored exactly" claim is
scoped to the default in-memory store; Redis rounds `ttl_millis` up to the next whole
second (500ms -> 1s, 1500ms -> 2s); `in_impl` emits a `#[doc(hidden)]` `{fn}_no_cache`
sibling (documented on all three macros); `#[concurrent_cached]` `force_refresh`
documents the `result_fallback` interaction; the `#[concurrent_cached]` attribute table
reaches parity with `#[cached]` (ttl_millis / force_refresh / in_impl rows); wasm is
incompatible with `redis_connection_manager` / `redis_async_cache`; the `in_impl`
shared-cache footgun; the async `V: Sync` clone-elision asymmetry, including how a
`Send + !Sync + !Clone` value surfaces at the generated set site; `CachedAsync`
shared-ref default Send bounds; `Cached::cache_get_or_set_with` /
`cache_try_get_or_set_with` flagged as provided defaults; migration-guide
`&mut V` -> `&V` coercion caveat
- added coverage: async clone-elision clone-count assertions; `#[concurrent_cached]`
`result_fallback` + `force_refresh` (including the no-read-side-effects bypass); `#[once]`
`force_refresh`; `force_refresh` + `in_impl`; generic `in_impl` rejection goldens for
`#[cached]` (free fn) and `#[concurrent_cached]` (in_impl method); compile-fail goldens
for `force_refresh`-unparseable on `#[once]` / `#[concurrent_cached]`, generic
`#[concurrent_cached]` without `convert`, and `ttl_millis` + `create` conflict;
`_mut` trait coverage on `ExpiringCache` / `TtlSortedCache`; redis `cache_clear` /
`cache_set_ref` and redb `cache_set_ref` round-trips; `TtlSortedCache` shared-ref
get-or-set delegation
- macro-output polish: ASCII-only macro diagnostics; no dead `#[doc]` on the
function-local `in_impl` cache static; documented rationale for `#[allow(dead_code)]`
on the generated prime companion and for the `crate_path()` `::cached` fallback
See docs/migrations/2.0-to-unreleased.md and the CHANGELOG for migration details.1 parent 35d07c3 commit 3a0790c
114 files changed
Lines changed: 7052 additions & 715 deletions
File tree
- .agents/skills
- pr-cycle
- pr-review
- .github/workflows
- bin
- cached_proc_macro
- src
- docs
- dev
- migrations
- examples
- src
- stores
- sharded
- tests
- ui
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
| 67 | + | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
111 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
| |||
157 | 158 | | |
158 | 159 | | |
159 | 160 | | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
173 | 201 | | |
174 | 202 | | |
175 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | | - | |
33 | | - | |
| 33 | + | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | | - | |
48 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
52 | | - | |
| 58 | + | |
| 59 | + | |
53 | 60 | | |
54 | 61 | | |
55 | 62 | | |
56 | | - | |
| 63 | + | |
57 | 64 | | |
58 | 65 | | |
59 | 66 | | |
60 | 67 | | |
61 | 68 | | |
62 | 69 | | |
| 70 | + | |
63 | 71 | | |
64 | 72 | | |
65 | 73 | | |
66 | | - | |
| 74 | + | |
67 | 75 | | |
68 | | - | |
69 | | - | |
70 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
71 | 92 | | |
72 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
73 | 96 | | |
74 | | - | |
| 97 | + | |
| 98 | + | |
75 | 99 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
80 | 104 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
87 | 115 | | |
88 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
89 | 139 | | |
90 | 140 | | |
91 | 141 | | |
92 | | - | |
| 142 | + | |
93 | 143 | | |
94 | 144 | | |
95 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
96 | 148 | | |
97 | | - | |
| 149 | + | |
98 | 150 | | |
99 | | - | |
100 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
101 | 155 | | |
102 | 156 | | |
103 | 157 | | |
| |||
110 | 164 | | |
111 | 165 | | |
112 | 166 | | |
113 | | - | |
| 167 | + | |
114 | 168 | | |
115 | 169 | | |
116 | 170 | | |
117 | 171 | | |
118 | | - | |
119 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
120 | 176 | | |
121 | 177 | | |
122 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
| 17 | + | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
21 | 32 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
0 commit comments