refactor(storage-manager): implement cache for History::Latest
#1454
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.
The changes introduced in #1367 were actually redundant (and incomplete): the method
is_latest
was checking that a received Sample was more recent than what is currently stored.This commit removes the redundant checks and implements a correct caching strategy by leveraging both approaches. The changes consist mostly in:
process_sample
method by one level.is_latest
method to check the cache first and only query the Storage if there is a cache miss.To help make potential concurrency issues visible, the method
is_latest
was renamed toguard_cache_if_latest
as the lock on the Cache should only be released when the Sample has been processed and the Cache updated.Additionally, the cache is filled at initialisation.
The
read_cost
configuration parameter was removed as it was not used and made obsolete with this change.plugins/zenoh-backend-example/src/lib.rs:
plugins/zenoh-backend-traits/src/lib.rs:
plugins/zenoh-plugin-storage-manager/src/memory_backend/mod.rs: removed the obsolete
read_cost
parameter.plugins/zenoh-plugin-storage-manager/src/storages_mgt/mod.rs:
StorageService::start
to also pass the Cache.plugins/zenoh-plugin-storage-manager/src/storages_mgt/service.rs
StorageService::start
to also pass the Cache.