Caching Data

Caching Data

Storing chat data locally within devices helps users retrieve their channels and messages even while offline. It can also prevent the inefficiency of repeating queries upon each connection or when device state change, as well as provide a desirable user experience by reducing data loading delays.

In the following basic and advanced pages, you can see how to build a local cache by using object serialization and deserialization, which is provided through the SDK. In the File caching: Basic page, we provide instructions on how to build a simple cache that stores the most recent messages and channels in a file. In the Database caching: Advanced page, you can find instructions on caching chat data in an internal database, which enables you to store structured and queryable data.

Caching with SendBird SyncManager

SendBird SyncManager is a library for chat data synchronization, which allows you to cache channels and messages of those channels in your client app reliably with a little effort. It listens to the events which happen on the channels in real-time and executes the background tasks for updating the cached data accordingly. You can use the cached data for a better user experience purposes, such as retrieving old messages in a channel view without requesting to SendBird server.

If you want a simple and fast caching implementation, download the SyncManager from our repository on GitHub and see the guide on how to add to your client app.

Download SyncManager

Note: The SyncManager includes SQLite as an internal database and operates based on it, which saves and stores the chat data synced with SendBird server for caching.