feat: TtlSortedCache::set_with builder, ConcurrentCachePeek, ConcurrentCachedExt::try_get_or_set_with - #297
Merged
Merged
Conversation
…currentCachedExt::try_get_or_set_with` Breaking: the `TtlSortedCache` inherent setters `set_with_ttl`, `set_evict`, and `set_with_ttl_evict` are replaced by a single entry-setter builder, `set_with(k, v).ttl(d).evict().set()`. `set_with_ttl_evict` took `Option<Duration>` while `set_with_ttl` took a bare `Duration`; the builder makes each option independent and gives one spelling per combination. Plain `set(k, v)` and `Cached::cache_set` are unchanged. `TtlSortedSetBuilder` is re-exported at the crate root and from `cached::stores`, gated on `time_stores`. `ConcurrentCachePeek<K, V>` moves the sharded `peek` onto a trait so generic code over a concurrent store can read without side effects: no recency promotion, no TTL refresh, no hit/miss metrics, and no lazy removal of expired entries. Only the six sharded stores implement it (`Error = Infallible`); the IO stores are excluded because they cannot peek without a full read. The concrete sharded types keep their inherent `peek`, which retains call-site priority. `ConcurrentCachedExt::try_get_or_set_with` completes the short-alias set for `ConcurrentCached::cache_try_get_or_set_with`, mirroring `CachedExt`. Also drops a no-op `#[allow(non_snake_case)]` from the `#[cached]` `Clone` assertion expansion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three v3 API changes plus a macro cleanup.
TtlSortedCacheinherent settersset_with_ttl/set_evict/set_with_ttl_evictwith an entry-setter builder:cache.set_with(k, v).ttl(d).evict().set().set_with_ttl_evicttookOption<Duration>whileset_with_ttltook a bareDuration; the builder makes each option independent and gives one spelling per combination. Plainset(k, v)andCached::cache_setare unchanged.TtlSortedSetBuilderis re-exported at the crate root and fromcached::stores, gated ontime_stores.ConcurrentCachePeek<K, V>, moving the shardedpeekonto a trait so generic code over a concurrent store can read without side effects: no recency promotion, no TTL refresh, no hit/miss metrics, no lazy removal of expired entries. Implemented by the six sharded stores only (Error = Infallible); the IO stores are excluded because they cannot peek without a full read. The concrete sharded types keep their inherentpeek, which retains call-site priority. Exported from the prelude.ConcurrentCachedExt::try_get_or_set_with, completing the short-alias set forConcurrentCached::cache_try_get_or_set_withto matchCachedExt.#[allow(non_snake_case)]from the#[cached]Cloneassertion expansion.Breaking changes are covered in the changelog and both migration guides. New coverage is in
tests/v3_ttl_sorted_set_with.rsandtests/v3_additive_parity.rs.