-
Notifications
You must be signed in to change notification settings - Fork 333
IndexedDB: Add implementation of MediaRetentionPolicy
-related functions in EventCacheStoreMedia
#5574
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
IndexedDB: Add implementation of MediaRetentionPolicy
-related functions in EventCacheStoreMedia
#5574
Conversation
Signed-off-by: Michael Goldenberg <[email protected]>
Signed-off-by: Michael Goldenberg <[email protected]>
Signed-off-by: Michael Goldenberg <[email protected]>
… to EventCacheStoreMedia implementation Signed-off-by: Michael Goldenberg <[email protected]>
…che database Signed-off-by: Michael Goldenberg <[email protected]>
…licy Signed-off-by: Michael Goldenberg <[email protected]>
…licy fns Signed-off-by: Michael Goldenberg <[email protected]>
Signed-off-by: Michael Goldenberg <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5574 +/- ##
==========================================
- Coverage 88.63% 88.63% -0.01%
==========================================
Files 340 340
Lines 95102 95102
Branches 95102 95102
==========================================
- Hits 84298 84296 -2
- Misses 6616 6619 +3
+ Partials 4188 4187 -1 ☔ View full report in Codecov by Sentry. |
CodSpeed Performance ReportMerging #5574 will not alter performanceComparing Summary
|
The matrix-rust-sdk/crates/matrix-sdk-base/src/event_cache/store/media/media_service.rs Lines 319 to 328 in f4ce435
The cleanup phase is done in a separate task. The task handle is stored here: matrix-rust-sdk/crates/matrix-sdk-base/src/event_cache/store/media/media_service.rs Lines 53 to 57 in f4ce435
If it is really annoying for you, we may want to revisit this. |
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.
It looks good to me, thanks!
Background
This pull request is part of a series of pull requests to add a full IndexedDB implementation of the
EventCacheStore
(see #4617, #4996, #5090, #5138, #5226, #5274, #5343, #5384, #5406, #5414, #5497, #5506, #5540). This particular pull request adds aMemoryStore
-backed implementation ofEventCacheStoreMedia
, as well as, IndexedDB-backed implementations forMediaRetentionPolicy
-related functions.Changes
The overarching change adds a
MemoryStore
-backed implementation ofEventCacheStoreMedia
forIndexeddbEventCacheStore
. Furthermore, the implementation ofEventCacheStore
now delegates to the implementation ofEventCacheStoreMedia
via aMediaService
nested inIndexeddbEventCacheStore
.Additionally, there are now implementations and tests for the following
EventCacheStoreMedia
functions.EventCacheStoreMedia::media_retention_policy_inner
IndexeddbEventCacheStoreTransaction::get_media_retention_policy
EventCacheStoreMedia::set_media_retention_policy_inner
And finally, to support these queries, the
CORE
object store now has a primary key with key pathid
.Caveats
EventCacheStoreMedia
requires that the implementing type beClone
able. Consequently, some rather minimal changes were required in order to supportClone
.There is, however, one notable change for supporting
Clone
, which is thatIndexeddbEventCacheStore.inner
went from being anIdbDatabase
to anRc<IdbDatabase>
.While this may seem like a problem in a concurrent environment, it is ultimately not an issue, as IndexedDB ensures that only a single transaction is running at a time. Any interfering transaction will be canceled by IndexedDB and return an error.
The downside of this architecture, however, is that it would require re-trying in a loop if multiple instances of
IndexeddbEventCacheStore
were contending for access.An alternative would be to use a
tokio::sync::Mutex
in conjunction with anArc
, which would replace the loop with anawait
. The consequences of this are that the implementation ofIndexeddbEventCacheStoreTransaction
becomes rather tricky, as it seems to require a self-referential struct.I'm not entirely sure why the
EventCacheStoreMedia
requiresClone
and how it will be used, so I opted for using anRc
as it was far more straightforward and still a sound approach.Future Work
EventCacheStoreMedia
functionsSigned-off-by: Michael Goldenberg [email protected]