using graphql with a cache to reduce database access

Viewed 46

Hey guys I'm a complete beginner in term of developing web application using node.js, react and so on.

So far I decided to use graphql and especially subscriptions to implement the communication between my server and client side. I wan't to build one server using graphql to provide the same data for every client side access. Because every client needs to see the exact same data set as everyone else.

And i want to try to cache the last fetched data from the Database until there is a reason to access the database again.

For example: When client one requests a list of books i want the server to cache the data. So that when client two does the same request it just gets the data that was last fetched from the database.

Its on my part to make sure the internal cache will be erased when the database table changed. But i don't want to request the Database every single time just to get the same answer 20 times in a row.

Is there a good way to cache the data inside the server ?

0 Answers
Related