Recall & Review
beginner
What does TTL stand for in the context of NestJS caching?
TTL stands for Time To Live. It defines how long cached data stays valid before it expires and is removed or refreshed.
Click to reveal answer
beginner
How do you set a global TTL for cache in a NestJS application?
You set a global TTL by configuring the CacheModule with the
ttl option in seconds, for example: CacheModule.register({ ttl: 5 }) sets a 5-second TTL for all cached items.Click to reveal answer
intermediate
Can TTL be set individually for different cache entries in NestJS?
Yes. When using the
@Cacheable() decorator or cache manager directly, you can specify a TTL per cache entry by passing the ttl option in seconds.Click to reveal answer
beginner
What happens when a cached item’s TTL expires in NestJS?
When TTL expires, the cached item is removed or considered stale. The next request will fetch fresh data and update the cache with a new TTL.
Click to reveal answer
intermediate
Why is TTL important in caching strategies?
TTL helps balance between performance and data freshness. It prevents serving outdated data too long and controls memory usage by removing old cache entries.
Click to reveal answer
In NestJS, what unit is TTL configured in when setting cache options?
✗ Incorrect
TTL in NestJS cache configuration is set in seconds.
Which NestJS module is used to configure TTL for caching?
✗ Incorrect
CacheModule is used to configure caching and TTL in NestJS.
If no TTL is set in NestJS CacheModule, what happens to cached data?
✗ Incorrect
Without TTL, cached data stays indefinitely until manually cleared.
How can you override the global TTL for a specific cache entry in NestJS?
✗ Incorrect
You can specify a ttl option per cache entry to override the global TTL.
What is the main benefit of setting a TTL on cached data?
✗ Incorrect
TTL ensures cached data is refreshed and does not become stale.
Explain how TTL configuration affects caching behavior in a NestJS application.
Think about how long cached data should be used before updating.
You got /4 concepts.
Describe how to set a global TTL and override it for a specific cache entry in NestJS.
Consider both module configuration and per-entry options.
You got /4 concepts.