Added support for a plain LRU (Least Recently Used) eviction policy
(#390[gh-pull-0390]):
The LRU policy is enabled by calling the eviction_policy method of the cache
builder with a policy obtained by EvictionPolicy::lru function.
The default eviction policy remains the TinyLFU (Tiny, Least Frequently Used)
as it maintains better hit rate than LRU for most use cases. TinyLFU combines
LRU eviction policy and popularity-based admission policy. A probabilistic data
structure is used to estimate historical popularity of both hit and missed
keys. (not only the keys currently in the cache.)
However, some use cases may prefer LRU policy over TinyLFU. An example is
recency biased workload such as streaming data processing. LRU policy can be
used for them to achieve better hit rate.
Note that we are planning to add an adaptive eviction/admission policy called
Window-TinyLFU in the future. It will adjust the balance between recency and
frequency based on the current workload.
Version 0.12.4
Fixed
Ensure crossbeam-epoch to run GC when dropping a cache (#384[gh-pull-0384]):
crossbeam-epoch crate provides an epoch-based memory reclamation scheme for
concurrent data structures. It is used by Moka cache to safely drop cached
entries while they are still being accessed by other threads.
crossbeam-epoch does its best to reclaim memory (drop the entries evicted
from the cache) when the epoch is advanced. However, it does not guarantee that
memory will be reclaimed immediately after the epoch is advanced. This means
that entries can remain in the memory for a while after the cache is dropped.
This fix ensures that, when a cache is dropped, the epoch is advanced and
crossbeam-epoch's thread local buffers are flushed, helping to reclaim memory
immediately.
Note that there are still chances that some entries remain in the memory for a
while after a cache is dropped. We are looking for alternatives to
crossbeam-epoch to improve this situation (e.g. #385[gh-issue-0385]).
Added
Added an example for reinserting expired entries to the cache.
(#382[gh-pull-0382])
Commits
b5560df Merge pull request #390 from moka-rs/lru-policy
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Bumps moka from 0.12.3 to 0.12.5.
Changelog
Sourced from moka's changelog.
Commits
b5560df
Merge pull request #390 from moka-rs/lru-policy27dd941
Tweak some doc commentsafc8c6b
Update the change loge11a6e1
Bump the version to v0.12.58819287
Fix typos in the doc4ca1595
Update the change log34cc03b
Support the plain LRU policyb32f05b
Apply rustfmt8ac62ed
Support the plain LRU policy2e904db
Merge pull request #386 from moka-rs/prepare-0.12.4Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show