-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(storage-manager): implement cache for
History::Latest
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: 1. Changing the outer test by continuing early if the Sample is detected as deleted. This allows lowering the overall indentation of the `process_sample` method by one level. 2. Modifying the behaviour of the `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 to `guard_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: - Populate the Cache at initialisation. - Updated the call to `StorageService::start` to also pass the Cache. * plugins/zenoh-plugin-storage-manager/src/storages_mgt/service.rs - Updated the call to `StorageService::start` to also pass the Cache. - "Reversed" the logic when checking if a Sample is deleted: if it is continue to the next one. This allows reducing the indentation level. - Keep the guard over the cache if a Sample is more recent and only release it once it has been updated (after the Sample has been successfully processed). Signed-off-by: Julien Loudet <[email protected]>
- Loading branch information
Showing
5 changed files
with
151 additions
and
133 deletions.
There are no files selected for viewing
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
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
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
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
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