-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Add the invalidate_entries_if
method
#12
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Create invalidator module. - Add thiserror crate to the dependencies.
- Implement iterator for deque.
Add invalidator thread pool
Implementing background invalidation task.
- Implementing background invalidation task. - Add the following trait bounds to the generic parameters of sync and future caches: - K: Send + Sync + 'static - V: 'static - S: Send + 'static
- Implementing background invalidation task. - Add Send + Sync bounds to a generic parameter V of sync and future caches, so K, V and S have the following bounds: - K: Send + Sync + 'static - V: Send + Sync + 'static - S: Send + 'static
- Remove finished predicates after a invalidation scan.
- Simplify the implementation of Predicate
- Tweak a unit test.
- Refactoring on the background invalidation task. - Add Sync bounds to a generic parameter S of sync and future caches, so now all K, V and S have the following bounds: - Send + Sync + 'static
- Add the invalidate_entries_if method to the future cache. - Add the support_invalidation_closures method to the builders in sync and future modules.
- Update the get methods in sync and future caches to check if the entry has been invalidated.
- Add invalidate_entries_if to the unsync cache.
- Simplify the implementation of invalidate_entries_if in the unsync cache.
Conflicts: CHANGELOG.md Cargo.toml
Write API doc.
- Add dependency to uuid crate and change the predicate ID type from u64 to PredicateId, which is String of UUID version 4. - Remove NoSpaceLeft variant from PredicateError as UUID collision will extreamly unlikely happens. - Rename PredicateRegistrationError to PredicateError. - Upgrade Quanta crate version from v0.7.1 to v0.8.0. - Write docs for PredicateId and PredicateError.
- Brush up the docs for unsync::Cache::invalidate_entries_if.
Conflicts: CHANGELOG.md src/sync/base_cache.rs src/sync/cache.rs
- Rename CacheBuilder::enable_invalidation_with_closures to support_invalidation_closures. - Remove an unused field from Invalidator.
- Implement `invalidate_entries_if` on `sync::SegmentedCache`. - Optimize `base_cache::Inner::submit_invalidation_task` method for a case when the write order queue is empty. - Refactor some cache methods for refactoring.
Fix a deadlock issue for dropping sync/future cache while running background invalidation task.
tatsuya6502
commented
Jun 20, 2021
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.
Merging.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the
invalidate_entries_if
method and supporting methods to all caches in Moka.invalidate_entries_if
invalidates the entire cache based on a predicate on the key and value of each cache entry. This method was requested by #10.Added
invalidate_entries_if
method to all cache implementations in Moka:sync::Cache
sync::SegmentedCache
future::Cache
unsync::Cache
support_invalidation_closures
method to the following cache builders:sync::CacheBuilder
future::CacheBuilder
sync
andfuture
caches, this method must be called at the cache creation time as the cache needs to maintain additional internal data structures to supportinvalidate_entries_if
method. Otherwise, callinginvalidate_entries_if
will return aPredicateError::InvalidationClosuresDisabled
.invalidator
module, containing a registry of invalidation predicates and a background invalidator (eviction) task.Iterator
on internalDeque
.Changed
base_cache::Inner
to run a newinvalidate_entries
method periodically.get
method insync
andfuture
caches to check if an entry has been invalidated.Fixes #10.