- Fix a bug caused
invalidate_all
andinvalidate_entries_if
of the following caches will not invalidate entries inserted just before calling them (#155):sync::Cache
sync::SegmentedCache
future::Cache
- Experimental
dash::Cache
- Add basic stats (
entry_count
andweighted_size
) methods to all caches. (#137) - Add
Debug
impl to the following caches (#138):sync::Cache
sync::SegmentedCache
future::Cache
unsync::Cache
- Remove unnecessary
K: Clone
bound from the following caches when they areClone
(#133):sync::Cache
future::Cache
- Experimental
dash::Cache
- Fix the following issue by upgrading Quanta crate to v0.10.0 (#126):
- Quanta v0.9.3 or older may not work correctly on some x86_64 machines where the Time Stamp Counter (TSC) is not synched across the processor cores. (#119)
- For more details about the issue, see the relevant section of the README.
- Add
get_with_if
method to the following caches (#123):sync::Cache
sync::SegmentedCache
future::Cache
The followings are internal changes to improve memory safety in unsafe Rust usages in Moka:
- Remove pointer-to-integer transmute by converting
UnsafeWeakPointer
fromusize
to*mut T
. (#127) - Increase the num segments of the waiters hash table from 16 to 64
(#129) to reduce the chance of the following issue occurring:
- Segfaults under heavy workloads on a many-core machine. (#34)
- Make Quanta crate optional (but enabled by default)
(#121)
- Quanta v0.9.3 or older may not work correctly on some x86_64 machines where the Time Stamp Counter (TSC) is not synched across the processor cores. (#119)
- This issue was fixed by Quanta v0.10.0. You can prevent the issue by upgrading Moka to v0.8.4 or newer.
- For more details about the issue, see the relevant section of the README.
- Add iterator to the following caches: (#114)
sync::Cache
sync::SegmentedCache
future::Cache
unsync::Cache
- Implement
IntoIterator
to the all caches (including experimentaldash::Cache
) (#114)
- Fix the
dash::Cache
iterator not to return expired entries. (#116) - Prevent "index out of bounds" error when
sync::SegmentedCache
was created with a non-power-of-two segments. (#117)
- Add
contains_key
method to check if a key is present without resetting the idle timer or updating the historic popularity estimator. (#107)
As a part of stabilizing the cache API, the following cache methods have been renamed:
get_or_insert_with(K, F)
→get_with(K, F)
get_or_try_insert_with(K, F)
→try_get_with(K, F)
Old methods are still available but marked as deprecated. They will be removed in a future version.
Also policy
method was added to all caches and blocking
method was added to
future::Cache
. They return a Policy
struct or BlockingOp
struct
respectively. Some uncommon cache methods were moved to these structs, and old
methods were removed without deprecating.
Please see #105 for the complete list of the affected methods.
- API stabilization. (Smaller core cache API, shorter names for common methods) (#105)
- Performance related:
- Update the minimum versions of dependencies:
- Add a synchronous cache
moka::dash::Cache
, which usesdashmap::DashMap
as the internal storage. (#99) - Add iterator to
moka::dash::Cache
. (#101)
Please note that the above additions are highly experimental and their APIs will be frequently changed in next few releases.
The minimum supported Rust version (MSRV) is now 1.51.0 (2021-03-25).
- Addressed a memory utilization issue that will get worse when keys have hight
cardinality (#72):
- Reduce memory overhead in the internal concurrent hash table (cht). (#79)
- Fix a bug that can create oversized frequency sketch when weigher is set. (#75)
- Change
EntryInfo
fromenum
tostruct
to reduce memory utilization. (#76) - Replace some
std::sync::Arc
usages withtriomphe::Arc
to reduce memory utilization. (#80) - Embed
CacheRegion
value into a 2-bit tag space ofTagNonNull
pointer. (#84)
- Fix a bug that will use wrong (oversized) initial capacity for the internal cht. (#83)
- Add
unstable-debug-counters
feature for testing purpose. (#82)
- Important Fix: A memory leak issue (#65 below) was found in all previous versions (since v0.1.0) and fixed in this version. All users are encouraged to upgrade to this or newer version.
- Fix a memory leak that will happen when evicting/expiring an entry or manually invalidating an entry. (#65)
- Update the minimum depending version of crossbeam-channel from v0.5.0 to v0.5.2. (#67)
- Breaking change: The type of the
max_capacity
has been changed fromusize
tou64
. This was necessary to have the weight-based cache management consistent across different CPU architectures.
- Add support for weight-based (size aware) cache management. (#24)
- Add support for unbound cache. (#24)
- Fix a bug in
get_or_insert_with
andget_or_try_insert_with
methods offuture::Cache
, which caused a panic if previously inserting task aborted. (#59)
- Remove
Send
and'static
bounds fromget_or_insert_with
andget_or_try_insert_with
methods offuture::Cache
. (#53)
- Protect overflow when computing expiration. (#56)
- Replace futures with futures-util. (#47)
- Fix a bug in
get_or_insert_with
andget_or_try_insert_with
methods offuture::Cache
andsync::Cache
; a panic in theinit
future/closure causes subsequent calls on the same key to get "unreachable code" panics. (#43)
- Change
get_or_try_insert_with
to return a concrete error type rather than a trait object. (#23, #37)
- Restore quanta dependency on some 32-bit platforms such as
armv5te-unknown-linux-musleabi
ormips-unknown-linux-musl
. (#42)
- Add support for some 32-bit platforms where
std::sync::atomic::AtomicU64
is not provided. (e.g.armv5te-unknown-linux-musleabi
ormips-unknown-linux-musl
) (#38)- On these platforms, you will need to disable the default features of Moka. See the relevant section of the README.
- Fix a bug in
get_or_insert_with
andget_or_try_insert_with
methods offuture::Cache
by adding missing boundsSend
and'static
to theinit
future. Without this fix, these methods will accept non-Send
or non-'static
future and may cause undefined behavior. (#31) - Fix
usize
overflow on big cache capacity. (#28)
- Add examples for
get_or_insert_with
andget_or_try_insert_with
methods to the docs. (#30)
- Downgrade crossbeam-epoch used in moka-cht from v0.9.x to v0.8.x as a possible workaround for segmentation faults on many-core CPU machines. (#33)
- Replace a dependency cht v0.4 with moka-cht v0.5. (#22)
- Add
get_or_insert_with
andget_or_try_insert_with
methods tosync
andfuture
caches. (#20)
- Breaking change: Now
sync::{Cache, SegmentedCache}
andfuture::Cache
requireSend
,Sync
and'static
for the generic parametersK
(key),V
(value) andS
(hasher state). This is necessary to prevent potential undefined behaviors in applications using single-threaded async runtime such as Actix-rt. (#19)
- Add
invalidate_entries_if
method tosync
,future
andunsync
caches. (#12)
- Stop skeptic from having to be compiled by all downstream users. (#16)
- Add an unsync cache (
moka::unsync::Cache
) and its builder for single-thread applications. (#9) - Add
invalidate_all
method tosync
,future
andunsync
caches. (#11)
- Fix problems including segfault caused by race conditions between the sync/eviction thread and client writes. (Addressed as a part of #11).
- Add an asynchronous, futures aware cache (
moka::future::Cache
) and its builder. (#7)
- Add thread-safe, highly concurrent in-memory cache implementations
(
moka::sync::{Cache, SegmentedCache}
) with the following features:- Bounded by the maximum number of elements.
- Maintains good hit rate by using entry replacement algorithms inspired by
Caffeine:
- Admission to a cache is controlled by the Least Frequently Used (LFU) policy.
- Eviction from a cache is controlled by the Least Recently Used (LRU) policy.
- Expiration policies:
- Time to live
- Time to idle