Recall & Review
beginner
What is the purpose of the CacheModule in NestJS?
CacheModule helps store data temporarily to speed up responses and reduce repeated work, like remembering answers to questions you've already asked.
Click to reveal answer
beginner
How do you import CacheModule globally in a NestJS application?Use CacheModule.register({ isGlobal: true }) inside the imports array of your root module to make caching available everywhere without re-importing.
Click to reveal answer
beginner
What option do you set to define how long cached data should live in CacheModule?
You set the 'ttl' (time to live) option in seconds, which tells the cache how long to keep data before removing it.
Click to reveal answer
beginner
Show a simple example of CacheModule setup with a 5-minute cache duration.
CacheModule.register({ ttl: 300 }) // 300 seconds = 5 minutes
Click to reveal answer
intermediate
Why might you want to use a cache store like Redis with CacheModule?
Redis stores cache outside your app memory, so cached data stays even if your app restarts, and it can be shared across multiple app instances.
Click to reveal answer
Which method imports CacheModule globally in NestJS?
✗ Incorrect
Use CacheModule.register with isGlobal: true to make cache available app-wide.
What does 'ttl' stand for in CacheModule options?
✗ Incorrect
'ttl' means how long cached data stays before expiring.
Which cache store is commonly used with CacheModule for persistent caching?
✗ Incorrect
Redis is a fast, in-memory store often used for caching.
What happens if you don't set 'ttl' in CacheModule?
✗ Incorrect
Without ttl, cached data stays indefinitely until manually cleared.
How do you enable caching in a specific service after importing CacheModule?
✗ Incorrect
Inject CACHE_MANAGER token to access cache methods in your service.
Explain how to set up CacheModule globally in a NestJS app and why you might want to do this.
Think about making caching easy to use in all parts of your app.
You got /4 concepts.
Describe the role of 'ttl' in CacheModule and how it affects cached data.
Consider how long you want your app to remember cached info.
You got /4 concepts.