You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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.
0 commit comments