Back

Node: Server side cache

  • 1
  • Databases
  • Functions
RodPenna
23 Nov, 2023, 02:18

Greetings, my name is Rodrigo and I'm working on a project where I have three collections as shown in the image below. The 'user' collection has user information, the 'product' collection has product information, and they have a 1-n relationship in both ways, so a user can obtain multiple different products subscriptions and a product may have several subscriptions from different users. To deal with this, I decide to create another collection called 'users_subscription' to be able to handle these relationships. The 'users_subscription' collection has an index on the 'id_product' attributes.

I have a function that is called periodically to inform me of users who have a particular subscription product, where I pass the product id and receive an array with the data of users who have a subscription. Below is an example of the function I am using to query the database.

My question is about using the cache in appwrite, and how do I use it in my queries, as I have fear that when the project scales, the search time will increase significantly due to the number of documents in the collection.

The way I'm doing it, am I already using the cache? If not, how and what methods would I use to be able to make use of the appwrite cache.

I would also like to know if there is any other approach to solving this problem.

Thank you very much for your attention!

TL;DR
1. Appwrite automatically handles data caching and only performs queries if data has changed. No need to worry about performance drops with large collections. 2. The user collection is used for sign-ins, while the users_subscription collection handles subscriptions and related data. It's recommended to use Appwrite's built-in authentication features. To use the Appwrite cache, you're already using it with your current setup. No additional steps needed. Alternative approaches to solve the problem were not mentioned in the conversation. Solution: - Utilize Appwrite's built-in caching for improved performance. - Consider using Appwrite's authentication features for user sign-ins.
ideclon
23 Nov, 2023, 02:43
  1. Re the caching, Appwrite has caching built in. There's nothing you need to do to activate it.
  2. Assuming your users and users_subscription Collections are actual users who are signing into your application, why don't you use Appwrite's built in Auth features?
RodPenna
23 Nov, 2023, 03:07

Many thanks for the reply.

  1. So appwrite automatically handles the data cache and it will only actually perform the query if the data has changed? Should I worry about a drop in performance if the collection becomes too large?
  2. Yes, the user collection is used to deal with sign-ins, but users_subscription is used to deal with subscriptions and then it has other data such as payment methods, etc., which I removed to simplify the example. It was the project manager's choice to do it this way, so I'm just following orders hehe
ideclon
23 Nov, 2023, 03:23

So you're not using Auth at all? How are you handling permissions?

RodPenna
23 Nov, 2023, 03:25

with proxy and api keys

ideclon
23 Nov, 2023, 03:26

So essentially you're just using Appwrite as a database?

RodPenna
23 Nov, 2023, 03:38

in short yes

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