There is so much that you can learn about on their official documentation. In this article, we have shown how you can use Redis with nodejs with a basic implementation. We can see that the time taken for the response is reduced from 1563ms to 33ms which is a huge change. Let us run this code and see the response on the postman to see the results. There are 9103 other projects in the npm registry using redis. Start using redis in your project by running npm i redis. In our case, searchtext is the key and the data from JSON placeholder API is its value. Latest version: 4.6.5, last published: 2 months ago. For geo-distributed Active-Active replication, create an Active-Active database. Create or join an existing Redis Enterprise Software cluster. Repeat this process for each node in the cluster. In case of cache not being there, the server will hit the external API and cache it for subsequent requests.Ĭtex() is the function that takes a key, its value, and duration for the validity of cache as an input. Redis Enterprise Software is now installed on the node. Inside the endpoint, we make Redis cache the data against a specific key and return the response if the appropriate cached data is available without hitting our external API. Firstly, we have initialized the Redis client on the port of choice. Let us explain what is happening in the above piece of code. During a recent redis update, we noticed that the node went down for few seconds. Const searchtext = Ĭlient.get(searchtext, async (err, data) => `)
0 Comments
Leave a Reply. |