Recall & Review
beginner
What is in-memory caching in Node.js?
In-memory caching stores data temporarily inside the server's memory to quickly reuse it without fetching or computing again. It helps speed up apps by avoiding slow operations.
Click to reveal answer
beginner
Name a common data structure used for in-memory caching in Node.js.
A JavaScript object or Map is often used to hold cached data as key-value pairs for fast lookup.
Click to reveal answer
intermediate
What is the purpose of a cache expiration or TTL (time-to-live)?
TTL sets how long cached data stays valid. After that, the cache removes or refreshes the data to keep it fresh and avoid stale info.
Click to reveal answer
intermediate
Explain the 'lazy loading' caching pattern.
Lazy loading means the cache only loads data when first requested. If data is missing, the app fetches it, stores it in cache, then returns it.
Click to reveal answer
advanced
What is the difference between write-through and write-back caching?
Write-through updates cache and main storage at the same time, ensuring consistency. Write-back updates cache first and writes to storage later, improving speed but risking data loss.
Click to reveal answer
Which data structure is best for fast key-value caching in Node.js?
✗ Incorrect
Map provides fast key-value access and better performance than arrays for caching.
What does TTL stand for in caching?
✗ Incorrect
TTL means Time To Live, the duration cached data remains valid.
In lazy loading caching, when is data loaded into the cache?
✗ Incorrect
Lazy loading caches data only when it is first requested.
Which caching pattern updates the main storage immediately when cache changes?
✗ Incorrect
Write-through caching updates both cache and storage at the same time.
What is a risk of using write-back caching?
✗ Incorrect
Write-back caching risks data loss if the server crashes before writing to storage.
Describe how you would implement a simple in-memory cache in Node.js with expiration.
Think about storing data with time info and checking it on each request.
You got /4 concepts.
Explain the differences and use cases for write-through and write-back caching patterns.
Consider speed versus data safety trade-offs.
You got /4 concepts.