Skip to content

Conversation

mgoldenberg
Copy link
Contributor

@mgoldenberg mgoldenberg commented Sep 1, 2025

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, #5574). This particular pull request adds types and migrations that will support storing media in IndexedDB via EventCacheStoreMedia.

Changes

Queries

Based on the SQLite-backed implementation of EventCacheStoreMedia, the following queries for interacting with stored media should be supported.

  1. Operate on media by MediaRequestParameters
  2. Operate on media by MediaSource
  3. Operate on media by last time it was accessed and whether it obeys the MediaRetentionPolicy.
  4. Operate on media by the size of its contents and whether it obeys the MediaRetentionPolicy.
  5. Operate on media by the last time it was accessed, the size of its contents, and whether it obeys the MediaRetentionPolicy.

Types

Two types have been added - Media and MediaMetadata to represent each media object in the database.

pub struct Media {
    pub metadata: MediaMetadata,
    pub content: Vec<u8>,
}

pub struct MediaMetadata {
    pub request_parameters: MediaRequestParameters,
    pub last_access: Duration,
    pub ignore_policy: IgnoreMediaRetentionPolicy,
}

The fields in MediaMetadata along with the size of Media::content after it is serialized, are used to derive keys for indexing Media in service of the queries above.

Schema

In order to support the queries above, the following object stores and indices have been created.

  • MEDIA - Object Store
  • MEDIA_SOURCE - Index on MEDIA
  • MEDIA_LAST_ACCESS - Index on MEDIA
    • Key - last_access - derived from Media.ignore_policy and Media.last_access
      • Supports query (3)
  • MEDIA_CONTENT_SIZE - Index on MEDIA
    • Key - content_size - derived from Media.ignore_policy and Media.content
      • Supports query (4)
  • MEDIA_RETENTION_METADATA - Index on MEDIA
    • Key - retention_metadata - derived from Media.ignore_policy, Media.last_access, and Media.content
      • Supports query (5)

Future Work

  • Add implementation of remaining functions in EventCacheStoreMedia

  • Public API changes documented in changelogs (optional)

Signed-off-by: Michael Goldenberg [email protected]

Copy link

codecov bot commented Sep 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.88%. Comparing base (e89ac3d) to head (f29be69).
⚠️ Report is 7 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5603      +/-   ##
==========================================
- Coverage   88.88%   88.88%   -0.01%     
==========================================
  Files         347      347              
  Lines       96275    96275              
  Branches    96275    96275              
==========================================
- Hits        85572    85571       -1     
- Misses       6674     6675       +1     
  Partials     4029     4029              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

codspeed-hq bot commented Sep 1, 2025

CodSpeed Performance Report

Merging #5603 will not alter performance

Comparing mgoldenberg:indexeddb-event-cache-store-media-schema (f29be69) with main (e89ac3d)

Summary

✅ 49 untouched benchmarks

@mgoldenberg mgoldenberg marked this pull request as ready for review September 1, 2025 04:40
@mgoldenberg mgoldenberg requested a review from a team as a code owner September 1, 2025 04:40
@mgoldenberg mgoldenberg requested review from poljar and removed request for a team September 1, 2025 04:40
@Hywan Hywan requested review from Hywan and removed request for poljar September 2, 2025 08:22
Copy link
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I've nothing to add! Thanks and well done!

@mgoldenberg mgoldenberg force-pushed the indexeddb-event-cache-store-media-schema branch from af923ca to f29be69 Compare September 2, 2025 13:24
@Hywan Hywan enabled auto-merge (rebase) September 2, 2025 13:26
@Hywan Hywan merged commit ee62cd7 into matrix-org:main Sep 2, 2025
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants