Complete the code to import the Redis client library in Node.js.
const redis = require('[1]');
We use require('redis') to import the Redis client library in Node.js.
Complete the code to create a Redis client using the modern Node.js Redis library.
const client = redis.[1]();The Redis client is created by calling redis.createClient().
Fix the error in the code to connect the Redis client asynchronously.
await client.[1]();The Redis client connects asynchronously using await client.connect().
Fill both blanks to set a key with a value and an expiration time in Redis.
await client.set('[1]', '[2]', { EX: 60 });
We set the key 'sessionId' with the value 'abcdef' and expiration of 60 seconds.
Fill all three blanks to get a cached value, check if it exists, and log it or a fallback message.
const cached = await client.[1]('[2]'); if (cached [3] null) { console.log('Cached value:', cached); } else { console.log('No cached value found'); }
We use client.get('userToken') to get the cached value, then check if it is not equal to null with !==.