v0.12.16
- Fixed a bug where cache eviction could stall permanently when the cache was configured with the non-default LRU eviction policy (
EvictionPolicy::lru()) by a race between insert and remove operations on the same key (#592 by @kim-jhyeon, reported in #590):- This bug was introduced in v0.12.0 and affected
sync::Cache,sync::SegmentedCacheandfuture::Cache. - A race between applying a write recording for an entry and concurrently removing that entry from the internal concurrent hash table could leave an orphaned node at the front of the LRU queue. Once present, no entry was ever evicted again and the cache grew unboundedly past
max_capacity. - The same race also affected the default TinyLFU eviction policy, but with a milder symptom: each occurrence permanently leaked one phantom entry slot, causing
entry_countandweighted_sizeto over-report and the usable capacity to shrink by one entry per occurrence. Fixed by the same change.
- This bug was introduced in v0.12.0 and affected
- Worked around a ThreadSanitizer false positive (#602):
- Replaced the standalone
fence(Acquire)in the internalMiniArc's drop path with anAcquireload of the reference count, so that downstream projects can now run ThreadSanitizer on code using Moka without hitting this false positive. std::sync::Archas a similar workaround.
- Replaced the standalone
- Raised the minimum version of the
crossbeam-epochcrate fromv0.9.18tov0.9.20to avoid the following advisory (#603):- [RUSTSEC-2026-0204] crossbeam-epoch: invalid pointer dereference in
fmt::PointerforAtomicandShared - Moka is not affected by this advisory because it never formats these pointer types. However, raising the minimum version prevents downstream lockfiles from resolving to an affected
crossbeam-epochversion via Moka.
- [RUSTSEC-2026-0204] crossbeam-epoch: invalid pointer dereference in
Moka 0.12.15
- Fixed a bug where re-inserting an expired entry could cause it to lose its expiration time and remain in the cache indefinitely when using a custom
Expirypolicy with per-entry expiration. (#582 by @jiangzhe, #581 by @atrocities, reported in #575):- This occurred when an entry that had expired but not yet been evicted was re-inserted, and
expire_after_updatereturnedNone. This primarily affected users who only overrideexpire_after_create, since the defaultexpire_after_updatereturnsduration_until_expiry, which isNonefor expired entries. - This bug was introduced by the changes in v0.12.13 (#549 and #564).
- Subtle behavior change:
- Before this fix, re-inserting an expired entry was treated as an update, so
Expiry::expire_after_updatewas called. - After this fix, re-inserting an expired entry is treated as a creation, so
Expiry::expire_after_createis called instead. - This may change the expiration time of re-inserted entries, depending on your
Expirytrait implementation.
- Before this fix, re-inserting an expired entry was treated as an update, so
- This occurred when an entry that had expired but not yet been evicted was re-inserted, and
- Fixed flaky tests
cht::segment::tests::drop_many_valuesanddrop_many_values_concurrentthat were failing on high-core-count machines (#586):- These tests were using a CPU-dependent segment count, causing inconsistent bucket array shrinking behavior of the internal segmented hash map across different machines.
- Changed these tests to use a fixed segment count (4) for consistent results.
Moka 0.12.14
- Fixed a race condition in the
and_compute_withmethod in thefuture::Cache. (#574 by @Squadrick):- When multiple calls are made concurrently for the same key, the
fclosure may read a stale value, causing the first update to be lost when it is overwritten by a later one.
- When multiple calls are made concurrently for the same key, the
- Use
dep:keyword in the crate features. (#577 by @alexanderkjall).
Moka 0.12.13
- Fixed/mitigated use-after-free issues in the hierarchical timer wheels when
ExpiryreturnsNone(Issue #565, reported by @sharksforarms). - Fixed
Expiry::expire_after_updatenot clearing expiration time for expired entries (future::Cache: #549, by @singulared,sync::Cache: #564).
Moka 0.12.12
Bumped the minimum supported Rust version (MSRV) to 1.71.1, released on August 3, 2023 (#555).