Update, delete local cache

On docs, it says we need to clear existing data source before adding api’s result to the local cache. How we clear and update the local cache? Also if setLimit(50) is set to messageCollection only 25 messages are retrieved from onApiResult callback and 15 from onCacheResult callback.

Hi @aayushthapa - thanks for reaching out to Sendbird!

I’m running some test for onCacheResult and onApiResult, updates to follow. In the meantime, can you please share the steps to recreate the setLimit scenario?

Here are some updates.

From my testing I’m observing that the cache is automatically getting refreshed without having to manually clear and update the cache. I have reached out to our engineering team to confirm the expected behavior.

About the setLimit(50) I noticed that it’s making two API calls - first with previous limit 25 and the second with the next limit 25. Since there are no messages after the current timestamp, it’s only returning the previous 25. Again, I have reached out to the engineering team to explain the expected behavior.

Hi @aayushthapa - only the view needs to be manually handled in onCacheResult and onApiResult. The cache is automatically updated.

Please refer to the following sample code.

@taha.saghir Thanks for the update. We are handling only views on those methods. Also, how can we get messages of length 50 on callback of both onCacheResult and onApiResult if messageCollection.setLimit(50) is used?

You can use the hasPrevious to paginate through the messages.