0
0
Node.jsframework~5 mins

In-memory caching patterns in Node.js - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AMap
BArray
CSet
DString
What does TTL stand for in caching?
ATime To Live
BTotal Time Limit
CTime To Load
DTemporary Transfer Limit
In lazy loading caching, when is data loaded into the cache?
AAt server startup
BNever loaded
CEvery minute automatically
DOnly when requested
Which caching pattern updates the main storage immediately when cache changes?
AWrite-back
BWrite-through
CLazy loading
DCache-aside
What is a risk of using write-back caching?
ASlower writes
BCache is always stale
CData loss if server crashes before storage update
DCache never updates
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.