Complete the code to import the NodeCache library.
const NodeCache = require('[1]');
The correct package name to import is node-cache.
Complete the code to create a new cache instance.
const cache = new NodeCache({ stdTTL: [1] });The stdTTL option sets the default time-to-live in seconds. 60 seconds is a common choice.
Fix the error in setting a cache value with key 'user' and value 'John'.
cache.[1]('user', 'John');
The method to store a value in the cache is set.
Fill both blanks to retrieve a cached value and handle a cache miss.
const value = cache.[1]('key'); if (value === [2]) { console.log('Cache miss'); }
null instead of undefined causes missed cache misses.Use get to retrieve the value. If the key is missing, get returns undefined.
Fill all three blanks to create a cache, set a value, and retrieve it.
const cache = new NodeCache({ stdTTL: [1] });
cache.[2]('color', 'blue');
const color = cache.[3]('color');We create a cache with TTL 120 seconds, set the key 'color' to 'blue', then get it back.
