Back

[Question] will there be a way for the SDK to manage and cache queries in the future?

  • 0
  • Databases
  • Flutter
  • General
  • Self Hosted
Ireneus
4 Feb, 2024, 16:10

if not does anybody know how a cache system should be structured, im assuming when i do the query calls i need to save the results by document id and whenever i query to check wether it has been called within a certain time limit?

TL;DR
Developers are asking if there will be a way for the SDK to manage and cache queries in the future. They discuss the issue with offline support and the difficulty of knowing what gets deleted or updated. One workaround suggested is saving things locally and creating a document to track updates. However, there's uncertainty about receiving changes through realtime and the feasibility of handling caching client-sided. It is recommended to check the provided link for more information. No definite solution is mentioned, but it is suggested that developers handle the caching system themselves by saving query results and checking if they have been called within a certain time limit.
D5
4 Feb, 2024, 16:24

Caching server-sided or client-sided?

Ireneus
4 Feb, 2024, 16:24

Client sided ofcourse

D5
4 Feb, 2024, 16:26

Not sure, but I think it's better to make that be handled by the user instead of the SDK. However this is a bit similar to offline support. Currently there is a repo in beta for flutter Offline support, maybe it has what you want

D5
4 Feb, 2024, 16:27

Since basically offline support is pretty similar to caching client sided 😅

Ireneus
4 Feb, 2024, 16:28

i know there is one for firebase but it does not support DocumentList types

D5
4 Feb, 2024, 16:29
D5
4 Feb, 2024, 16:31

But from what I'm seeing it gets everything by default so it only uses cache when network isn't available

D5
4 Feb, 2024, 16:32

The "Issue" is that you don't/can't know if something got or not updated

Ireneus
4 Feb, 2024, 16:34

well they could check these documents with realtime subscription?

D5
4 Feb, 2024, 16:35

I think not, since when something changes, the app could be in the background and not receive the changes through realtime

Ireneus
4 Feb, 2024, 16:35

oh i see

D5
4 Feb, 2024, 16:38

A workaround I recommend is saving things locally and then creating a doc called updated, for example. That doc has an integer attribute (for example, 0). Once you create a new document, you increase that number by 1. Once the app is opened, you check if that value has increased respect the saved (if so, you update since there's a new document that has been added), and if it's the same, you don't need to get anything (so you use cached elements)

D5
4 Feb, 2024, 16:39

The issue would be if some document get's updated or deleted instead of added

D5
4 Feb, 2024, 16:40

Then you will need to have a different attrubute and if there is a delete or update, get again all documents

Ireneus
4 Feb, 2024, 16:43

how would i know what gets deleted or updated id have to do realtime checks again

Ireneus
4 Feb, 2024, 16:43

and that for each document?

Ireneus
4 Feb, 2024, 16:43

oh nvm

Ireneus
4 Feb, 2024, 16:44

yeah thats the same issue with offline support

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more