cached
Generic cache implementations and simplified function memoization
2.0.2
42M downloads/mo
#1385 most downloaded on crates.io
jaemk/cached
What this package is like to depend on
Last release 19 days ago
04 Aug 2026
Ships unpredictably
gaps range from 8 days to 8 months
No release notes found
nothing matched a version
1 version withdrawn
withdrawn after publishing
9 years old
107 releases · first in 2017
18 releases in the last 12 months
see the full history below
Release timeline
107 releases · Mar 2017 to Aug 2026Releases
latest 60 of 107-
3.0.0-rc.1004 Aug 2026 pre-releaseRelease notes
Open source →What's Changed
- feat: bound trait
Errortypes, addcache_contains,peek/resetaliases by @jaemk in #290 - feat: require unbounded
cache_contains, peek-basedcontainsparity, remove inherentTtlSortedCache::set_ttlby @jaemk in #291 - release: 3.0.0-rc.9 by @jaemk in #292
- feat: remove
CacheSetError, renameTtlSortedCacheinsert*toset*, wrap order-method values inCacheValueby @jaemk in #293 - feat: sharded
peek, buildernew(), ext alias parity, concurrentcache_try_get_or_set_with,retainon map stores by @jaemk in #294 - docs: fix
cache_containsimplementor listing and docsrs gate, noteArc<T>return pattern, addpeekrecency test by @jaemk in #295 - fix: clear
Cloneerror for#[cached]return types,async_coredocsrs badges, doc and spec corrections by @jaemk in #296 - feat:
TtlSortedCache::set_withbuilder,ConcurrentCachePeek,ConcurrentCachedExt::try_get_or_set_withby @jaemk in #297 - feat:
retainonTtlSortedCacheand the six sharded stores by @jaemk in #298 - perf: in-memory and sharded store speedups; promote on
cache_setoverwrite by @jaemk in #299 - feat: derive default shard count from
max_size, makecache_containsdyn-callable by @jaemk in #300 - feat: count evictions before
on_evict, clearCloneerror for#[once], no-callbackretainfast path by @jaemk in #301 - 3.0.0-rc.10:
retainreturns removed count,ConcurrentCachePeekAsync, MSRV 1.92 by @jaemk in #302
Full Changelog: cached_proc_macro_types-v3.0.0-rc.8...v3.0.0-rc.10
- feat: bound trait
-
3.0.0-rc.920 Jul 2026 pre-releaseRelease notes
Open source →Breaking Changes
Cached::ErrorandConcurrentCacheBase::Errorare now bounded by
std::error::Error + Send + Sync + 'static. Custom store implementations whose error
type does not implementstd::error::Error(or is notSend/Sync/'static) must update
theirtype Error. All built-in stores (Infallible,CacheSetError,RedisCacheError,
RedbCacheError) already satisfy the bound. See the migration guide for detection and remediation.ConcurrentCached::cache_containsandConcurrentCachedAsync::async_cache_containsare now
required methods, no longer defaulted, and no longer carry aV: Clone(async:V: Clone + Send)
bound. External implementors ofConcurrentCached/ConcurrentCachedAsyncmust add these
methods; the previous defaulted version only ever shipped in 3.0.0 rcs. Rationale: theV: Clone
bound blockedcontainsfor non-Clone value types and could not be relaxed after 3.0.0 without
another breaking change.ConcurrentCachedExt::containsalso drops itsV: Clonebound.TtlSortedCache::set_ttlinherent method removed. Runtime TTL controls are now only on the
traits:CacheTtlfor single-owner stores,ConcurrentCacheTtlfor concurrent stores. Migration:
use cached::CacheTtl;and the samecache.set_ttl(d)call compiles with identical semantics.CachedExt::containsnow delegates toCached::cache_contains(new, defaulted; built-ins
override with a peek-based implementation) instead ofcache_get. As a resultcontainsno
longer counts a hit/miss, promotes LRU recency, or refreshes TTL on refresh-on-hit stores, and
reports expired entries as absent. This only affects the rc surface; the trait-level default of
Cached::cache_containsremains get-based for third-party stores that do not override it.
Added
CachedPeek::peek: ergonomic alias forcache_peek.CloneCached::peek_with_expiry_status: ergonomic alias forcache_peek_with_expiry_status.ConcurrentCloneCached::peek_with_expiry_status: ergonomic alias for
cache_peek_with_expiry_statuson the concurrent clone trait.CachedExt::reset: ergonomic alias forCached::cache_reset, mirroring the existing
ConcurrentCachedExt::reset.Cached::cache_contains<Q>(&mut self, k: &Q) -> bool: defaulted presence check on the core
single-owner trait (default get-based; built-in stores override with a peek-based implementation).
CachedExt::containsdelegates to it, givingcontainsboth spellings on both trait families.ConcurrentCached::cache_contains: required presence check returningResult<bool, Self::Error>,
noV: Clonebound. The built-in sharded stores use a peek-based implementation (read lock, no
clone, no recency update, no hit/miss metrics);RedisCache/RedbCache
use a get-based implementation. External implementors ofConcurrentCachedmust add this method.ConcurrentCachedAsync::async_cache_contains: required async counterpart ofcache_contains,
noV: Clone + Sendbound; same impl split as the sync method. External implementors of
ConcurrentCachedAsyncmust add this method.ConcurrentCachedExt::contains: ergonomic alias forcache_contains, noV: Clonebound.- Inherent
contains(&self, &K) -> boolon all six sharded stores: peek-based, infallible,
takes call-site priority overConcurrentCachedExt::contains(consistent with the other
inherent shims likeget/set/reset). ExpiringLruCache::iter_order/key_order/value_order: recency-order introspection
matchingLruCache(plain(K, V)/K/Vshapes; expired entries excluded), completing
the LRU-family parity started withretain.#[must_use]onConcurrentCached::cache_removeandcache_remove_entry, their
ConcurrentCachedAsynccounterpartsasync_cache_remove/async_cache_remove_entry, and the
ConcurrentCachedExtaliasesremove/remove_entry.#[must_use]onRedbCacheError::is_deserialization, matchingRedisCacheError::is_deserialization.#[cfg_attr(docsrs, doc(cfg(feature = "time_stores")))]on theShardedTtlCache*and
ShardedLruTtlCache*re-exports insrc/stores/sharded/mod.rs.
Changed
encode_ttl/decode_ttldeduplicated fromsrc/stores/sharded/ttl.rsand
src/stores/sharded/lru_ttl.rsinto a singlepub(crate)copy in
src/stores/sharded/mod.rs; both files now import from there. No behavior change.
Documentation
- Prelude doc corrected: it re-exports both traits and the
CacheMetricsstruct, not traits only. - The
compile_failsnippet forcache_get_or_set_withincludes a leading comment making its
non-compiling intent clear in the generated README (wherecompile_failrenders as plain Rust). docs/migrations/2.0-to-3.0-human.md: added section onReturn<T>field privatization
(r.value/r.was_cached-> deref /into_inner()/was_cached()).docs/migrations/2.0-to-3.0.mdand2.0-to-3.0-human.md: added theCached::Errorand
ConcurrentCacheBase::Errorbound as a breaking change entry.specs/traits-core.mdandspecs/traits-concurrent.md: updated to recordErrorbounds,
peekaliases,reset,cache_contains/async_cache_contains/contains.docs/migrations/2.0-to-3.0.mdand2.0-to-3.0-human.md: added entries for required
cache_contains/async_cache_contains,TtlSortedCache::set_ttlinherent removal, and the
single-ownercontainssemantic change.specs/traits-core.md: addedCached::cache_containsdefaulted method and updated
CachedExt::containsdelegation.specs/traits-concurrent.md: updatedcache_contains/async_cache_containsto required,
unbounded; updated ext alias and IO store impls.specs/store-sharded.md: added inherentcontainsto the sharded store inherent-shim list.
-
3.0.0-rc.817 Jul 2026 pre-releaseRelease notes
Open source →What's Changed
- docs: show expires = true with Result and Option returns in expires_per_key example by @jaemk in #269
- chore: update hashbrown to 0.17, criterion to 0.8, googletest to 0.14 by @jaemk in #270
- redb DiskCache backend and API cleanups (staged for next major) by @jaemk in #271
- feat: macros, stores/traits, redis TLS split, runtime decoupling, constructor and ttl consistency by @jaemk in #272
- release: 3.0.0-rc.1 by @jaemk in #273
- v3 API changes, security hardening, and macro guards by @jaemk in #274
- 3.0 pre-release fixes: sync_writes revert, redis feature axes,
CachedGetOrSetAsyncby @jaemk in #276 - 3.0.0-rc.3: freeze the v3 API, behavior and docs fixes, test/CI hardening by @jaemk in #277
- 3.0.0-rc.4: rc.3 review fixes (behavior, packaging, docs) by @jaemk in #278
- 3.0.0-rc.5: v3 review fixes (behavior, breaking API, docs, specs) by @jaemk in #279
- restructure specs into a feature inventory by @jaemk in #280
- 3.0.0-rc.6: pre-release review fixes (behavior, api, docs) by @jaemk in #281
- test: widen the async redb eviction race ttl to match the sync test by @jaemk in #282
- 3.0.0-rc.7: pre-release review fixes (redis prefix guard, redb dir self-heal, docs, example CI) by @jaemk in #283
- reject inert
sync_writes_buckets, drop expiring-store struct bounds, deriveConnectionStringeq, store format and doc fixes by @jaemk in #284 - feat: add runtime
set_max_sizeto sharded LRU stores, renameRedbCacheBuilder::disk_dir, addresilienceexample by @jaemk in #285 - Trait-only sharded ttl controls, per-shard initial capacity,
ExpiringLruCache::retain, docs and spec fixes by @jaemk in #286 - rename
SetMaxSizeError::ZeroSizetoZeroMaxSize, document redis/redb format stability, correct spec drift by @jaemk in #287 - fix:
Acquireload for shardedmetrics().capacity, document concurrentset_max_sizesemantics, sync specs by @jaemk in #288 - release: 3.0.0-rc.8 by @jaemk in #289
Full Changelog: v2.0.2...v3.0.0-rc.8
-
3.0.0-rc.712 Jul 2026 pre-releaseNothing published for this version
-
3.0.0-rc.611 Jul 2026 pre-releaseNothing published for this version
-
3.0.0-rc.507 Jul 2026 pre-releaseNothing published for this version
-
3.0.0-rc.406 Jul 2026 pre-releaseNothing published for this version
-
3.0.0-rc.305 Jul 2026 pre-releaseNothing published for this version
-
3.0.0-rc.202 Jul 2026 pre-releaseNothing published for this version
-
3.0.0-rc.121 Jun 2026 pre-releaseNothing published for this version
-
2.0.207 Jun 2026Nothing published for this version
-
2.0.106 Jun 2026Nothing published for this version
-
2.0.006 Jun 2026Nothing published for this version
-
1.1.025 May 2026Nothing published for this version
-
1.0.021 May 2026Nothing published for this version
-
0.59.022 Mar 2026Nothing published for this version
-
0.58.009 Mar 2026Nothing published for this version
-
0.57.009 Mar 2026Nothing published for this version
-
0.56.022 Jul 2025Nothing published for this version
-
0.55.103 Mar 2025Nothing published for this version
-
0.55.003 Mar 2025 withdrawnNothing published for this version
-
0.54.006 Nov 2024Nothing published for this version
-
0.53.123 Jul 2024Nothing published for this version
-
0.53.020 Jul 2024Nothing published for this version
-
0.52.003 Jul 2024Nothing published for this version
-
0.51.413 Jun 2024Nothing published for this version
-
0.51.308 May 2024Nothing published for this version
-
0.51.207 May 2024Nothing published for this version
-
0.51.105 May 2024Nothing published for this version
-
0.51.003 May 2024Nothing published for this version
-
0.50.026 Apr 2024Nothing published for this version
-
0.49.307 Apr 2024Nothing published for this version
-
0.49.224 Feb 2024Nothing published for this version
-
0.49.124 Feb 2024Nothing published for this version
-
0.49.024 Feb 2024Nothing published for this version
-
0.48.122 Jan 2024Nothing published for this version
-
0.48.022 Jan 2024Nothing published for this version
-
0.47.003 Jan 2024Nothing published for this version
-
0.46.106 Nov 2023Nothing published for this version
-
0.46.024 Sep 2023Nothing published for this version
-
0.45.106 Sep 2023Nothing published for this version
-
0.45.005 Sep 2023Nothing published for this version
-
0.44.003 Jun 2023Nothing published for this version
-
0.43.011 Apr 2023Nothing published for this version
-
0.42.004 Jan 2023Nothing published for this version
-
0.41.017 Dec 2022Nothing published for this version
-
0.40.023 Oct 2022Nothing published for this version
-
0.39.002 Sep 2022Nothing published for this version
-
0.38.002 Aug 2022Nothing published for this version
-
0.37.017 Jul 2022Nothing published for this version
-
0.36.004 Jul 2022Nothing published for this version
-
0.35.004 Jul 2022Nothing published for this version
-
0.34.111 Jun 2022Nothing published for this version
-
0.34.010 Mar 2022Nothing published for this version
-
0.33.001 Mar 2022Nothing published for this version
-
0.32.126 Feb 2022Nothing published for this version
-
0.32.026 Feb 2022Nothing published for this version
-
0.31.025 Feb 2022Nothing published for this version
-
0.30.021 Jan 2022Nothing published for this version
-
0.29.012 Jan 2022Nothing published for this version