Skip to content

Persistent event cache for timeline event #419

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

Closed
wants to merge 6 commits into from

Conversation

alanpoon
Copy link
Contributor

@alanpoon alanpoon commented Mar 4, 2025

Fixes #164

  1. Added Event_cache enable storage before client's synchronization
  2. Added "use_cache" boolean for MatrixRequest::PaginateRoomTimeline
  3. Added logic to decide whether to do timeline pagination based on event cache's length.

There is not need to manually add initial event to event cache because there is synchronization. EventCache::add_initial_events()

There is also no need to use Clientbuilder.sqlite_store_with_cache_path method as it just separates the cache path from the app data.

@alanpoon alanpoon self-assigned this Mar 4, 2025
@alanpoon alanpoon marked this pull request as ready for review March 4, 2025 08:45
@alanpoon alanpoon added the waiting-on-review This issue is waiting to be reviewed label Mar 4, 2025
Copy link
Member

@kevinaboos kevinaboos left a comment

Choose a reason for hiding this comment

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

Oh great! I wasn't sure if the SDK even supported this yet. However, I did just update to the most recent version of the SDK's main branch yesterday, so we should double-check that again to see what's changed.

Can you clarify exactly what level of support for event caching is implemented by this PR? I'm curious, because the kind of event caching behavior that I was describing in #164 is a full save and restore of all known events in all rooms, which is essentially equivalent to what Element Web/Desktop can do.
If we do add full support for saving/restoring the EventCache, then we'll also need to add a few other features before we merge this in:

  • loading a room's timeline not at the very bottom by default, but at the point where it was last read.
  • Implementing a "jump upwards to last read message" feature.
  • Supporting timelines in "focused" mode (non-"live" mode), where you can paginate both backwards and forwards (which would now be required since we wouldn't be starting the timeline from the newest possible message.
  • probably some other things too

But if this PR isn't doing that level of cache restore, then we can worry about it later when we do add full save/restore.

@kevinaboos kevinaboos added waiting-on-author This issue is waiting on the original author for a response and removed waiting-on-review This issue is waiting to be reviewed labels Mar 6, 2025
@alanpoon
Copy link
Contributor Author

alanpoon commented Mar 6, 2025

Oh great! I wasn't sure if the SDK even supported this yet. However, I did just update to the most recent version of the SDK's main branch yesterday, so we should double-check that again to see what's changed.

Can you clarify exactly what level of support for event caching is implemented by this PR? I'm curious, because the kind of event caching behavior that I was describing in #164 is a full save and restore of all known events in all rooms, which is essentially equivalent to what Element Web/Desktop can do. If we do add full support for saving/restoring the EventCache, then we'll also need to add a few other features before we merge this in:

  • loading a room's timeline not at the very bottom by default, but at the point where it was last read.
  • Implementing a "jump upwards to last read message" feature.
  • Supporting timelines in "focused" mode (non-"live" mode), where you can paginate both backwards and forwards (which would now be required since we wouldn't be starting the timeline from the newest possible message.
  • probably some other things too

But if this PR isn't doing that level of cache restore, then we can worry about it later when we do add full save/restore.

Screenshot 2025-03-06 at 1 25 00 PM
This screen shows the log of the Length of the event cache of the timeline. It is not 0. I am assuming that this proves that there is on-disk event caching and the timeline is displaying the events from the event cache. I have verified that "sqlite3 matrix-sdk-event-cache.sqlite3" followed by "SELECT * FROM events;" contains the cache.

Maybe I will continue this after #422 is being merged. I should also add to support no internet.

@alanpoon alanpoon closed this Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-on-author This issue is waiting on the original author for a response
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Save and restore event cache to/from persistent storage
2 participants