user2989745
user2989745

Reputation: 147

How to implement caching system?

I'm developing a web application where the backend, developed in spring boot, consumes data from a public API that returns data in JSON. The search is done through terms, full-text (like a google), the backend receives from the application frontend to the user's query, which in turn searches the public API, waits for a response, handles the information and sends it to the frontend. I wanted to implement the caching system in the backend, Spring Boot. Basically, before the spring boot makes a call to the API publishes and wait for the response, it checks on a key/value system if the search has already been done in the past, if yes, return what is in the value of the key.

The caching system:

Initially I thought of using a NoSQL database, such as mongoDB. But after investigating better, I came across Redis. What do you think is best?

I would like to ask some suggestions to implement this architecture. I'm not sure how to implement it, I doubt both Redis or MongoDB or other.

Thanks.

Upvotes: 0

Views: 579

Answers (2)

Artemy Prototyping
Artemy Prototyping

Reputation: 160

You can use MemCache. It's ready system for caching.

Upvotes: 0

RoninDev
RoninDev

Reputation: 5666

I am not sure cache will help you much in this case, because of different forms of search words.

If you need to protect your backend from multiple executions of the same query, you can use Spring Cache. It supports different providers including Redis and has evict mechanism

Upvotes: 1

Related Questions