Caching API Responses with Redis



Caching API Responses with Redis

Caching API Responses with Redis

Let’s implement a simple cache with Redis and the Open Weather API! Justin demonstrates how to cache third-party API responses using node.js, ioredis, axios, and Redis!

The complete application can be found at https://github.com/redis-developer/redis-caching-api-responses

$ git clone [email protected]:redis-developer/redis-caching-api-responses

See the application README for complete instructions

▬ Links ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
00:00 – Introduction
00:53 – Initializing Project
02:04 – Creating endpoint function
03:56 – Creating getWeather function
04:16 – Initializing API request
04:43 – Returning API response as JSON object
06:00 – Running file with API only
07:06 – Timing the API Request/Response
08:13 – Running file with timing
08:34 – Adding a Redis GET
09:05 – Connecting to Redis
09:46 – We have some complaints
10:09 – Starting Redis Docker image
10:28 – Checking Redis for cache entry
13:09 – Returning our cached entry
14:38 – Writing the Redis SET
15:40 – Running file with API then cached responses
17:12 – Preventing cache staleness
18:40 – Implementing key expiration in Redis
19:00 – Running file with expiry
20:30 – Checking expiration with TTL command
21:06 – Wrap-up and fare thee well

Need a Redis cluster now? Sign up for a free Redis Cloud Essentials account → https://bit.ly/2wasiCa

Join our Discord server → https://discord.gg/redis

RedisInsight → https://redislabs.com/redis-enterprise/redis-insight/
Redis University → https://university.redislabs.com/
Redis Labs → https://redislabs.com/

Comments are closed.