Commit 87f58a3
authored
Removes the associated const `PREFIX_CACHE` from the `CacheKey` trait,
and supporting macro APIs.
This diff should be non-breaking in that the key strings should be the
same as before, just without the API confusion.
## Motivation
Formerly it was possible to specify an override for the prefix of cache
keys via an optional 3rd arg to `kv_def!`, and `string_kv_def!`.
The issue is, the override (or the default when omitted) are not
included in the actual string form of the key unless you explicitly
`format!()` it in there.
This is to say, the following are equivalent:
```rust
// specify the override, then manually format it in.
kv_def!(KeyA, ValA, "MY_PREFIX")
impl KeyA {
pub fn new(x: &str) -> Self {
Self(format!("{Self::PREFIX_CACHE}_{x}"))
}
}
// no override, so `Self::PREFIX_CACHE` is whatever the default is, but
// it doesn't matter... it's not included in the key string :(
kv_def!(KeyA, ValA)
impl KeyA {
pub fn new(x: &str) -> Self {
// Including the prefix here means this version of KeyA is equiv
Self(format!("MY_PREFIX_{x}"))
}
}
```
The problem comes when you omit `Self::PREFIX_CACHE` in the key string
itself. The assumption would be either the default prefix, or an
override when specified, would be included in the string automatically,
but it isn't.
## Solution
Removing the confusing 3rd arg from the macros and eliminating the
associated const should mean moving forward: "wysiwyg." If there's a
prefix in the key string, that's the prefix. There's no need for
defaults or overrides.
File tree
4 files changed
+9
-28
lines changed- server/svix-server/src
- core
- cache
4 files changed
+9
-28
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| |||
74 | 73 | | |
75 | 74 | | |
76 | 75 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | 76 | | |
86 | 77 | | |
87 | 78 | | |
| |||
115 | 106 | | |
116 | 107 | | |
117 | 108 | | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | 109 | | |
127 | 110 | | |
128 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
| 217 | + | |
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 85 | + | |
| 86 | + | |
90 | 87 | | |
91 | 88 | | |
92 | 89 | | |
| |||
0 commit comments