Recall & Review
beginner
What is in-memory caching in the context of a Node.js server?
In-memory caching stores data temporarily inside the server's memory (RAM) to quickly serve repeated requests without recalculating or fetching from a database.
Click to reveal answer
beginner
What is the main purpose of the
node-cache library?node-cache provides a simple way to store and retrieve data in memory with expiration times, helping improve app speed by avoiding repeated heavy operations.Click to reveal answer
intermediate
How do you set a value in
node-cache with a time-to-live (TTL)?Use
cache.set(key, value, ttlInSeconds). The TTL defines how long the data stays in cache before it expires.Click to reveal answer
intermediate
What happens when you try to get a key from
node-cache that has expired or does not exist?The
get method returns undefined, indicating the data is not available in cache and may need to be fetched or recalculated.Click to reveal answer
beginner
Why is in-memory caching not suitable for storing very large data or permanent storage?
Because memory is limited and data is lost when the server restarts, in-memory caching is best for small, temporary data to speed up responses.
Click to reveal answer
Which of the following best describes
node-cache?✗ Incorrect
node-cache is used for temporary in-memory data storage with TTL, not permanent storage or UI.How do you retrieve a cached value using
node-cache?✗ Incorrect
The
get method retrieves the value stored under the given key.What does TTL stand for in caching?
✗ Incorrect
TTL means Time To Live, the duration data stays valid in cache.
If a cached item expires, what will
cache.get(key) return?✗ Incorrect
Expired or missing keys return
undefined in node-cache.Which scenario is best suited for using
node-cache?✗ Incorrect
Caching API responses temporarily speeds up repeated requests without permanent storage.
Explain how you would use
node-cache to improve performance in an Express app.Think about saving repeated data to avoid slow operations.
You got /5 concepts.
What are the limitations of using in-memory caching with
node-cache?Consider what happens when the server stops or restarts.
You got /4 concepts.