-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: introduce CacheBuilder
for in-memory cache
#350
Conversation
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
cc @xiaguan |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #350 +/- ##
==========================================
+ Coverage 76.68% 76.74% +0.05%
==========================================
Files 53 53
Lines 6343 6376 +33
==========================================
+ Hits 4864 4893 +29
- Misses 1479 1483 +4 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
foyer-memory/src/cache.rs
Outdated
self | ||
} | ||
|
||
pub fn with_eviction_config(mut self, eviction_config: EvictionConfig) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can even be fn with_eviction_config(mut self: eviction_config: impl Into<EvictionConfig>)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sensei!!!
Signed-off-by: MrCroxx <mrcroxx@outlook.com>
👍 |
* feat: introduce `CacheBuilder` for in-memory cache Signed-off-by: MrCroxx <mrcroxx@outlook.com> * refactor: further simplify builds Signed-off-by: MrCroxx <mrcroxx@outlook.com> --------- Signed-off-by: MrCroxx <mrcroxx@outlook.com>
let eviction_config = self.eviction_config.unwrap_or(Self::DEFAULT_EVICTION_CONFIG); | ||
let object_pool_capacity = self | ||
.object_pool_capacity | ||
.unwrap_or(capacity / Self::DEFAULT_OBJECT_POOL_CAPACITY_RATIO_RECIPROCAL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to DEFAULT_OBJECT_POOL_CAPACITY_RATIO_RECIPROCAL==10
, the capacity must greater than 9. Otherwise, it will panic due to zero object pool capacity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fotgot the AsyncQueue
capacity cannot be 0. Let me open an issue.
What's changed and what's your intention?
Introduce
CacheBuilder
to make in-memory cache build much easier.Thanks @wenym1 for help. 🙏
Before (with default args):
After (with default args):
Checklist
make all
(ormake fast
instead if the old tests are not modified) in my local environment.Related issues or PRs (optional)
#327