Bird
0
0

Why is it important to import CacheModule with proper options when using CacheInterceptor in NestJS?

hard📝 Conceptual Q10 of 15
NestJS - Interceptors
Why is it important to import CacheModule with proper options when using CacheInterceptor in NestJS?
ABecause CacheModule provides decorators to mark methods as cacheable.
BBecause CacheModule automatically applies CacheInterceptor to all controllers.
CBecause CacheModule configures the cache store and TTL, enabling CacheInterceptor to function correctly.
DBecause CacheModule replaces the default HTTP request handler with a cached version.
Step-by-Step Solution
Solution:
  1. Step 1: Understand CacheModule role

    CacheModule sets up the cache store (memory, redis, etc.) and TTL settings used by CacheInterceptor.
  2. Step 2: Clarify misconceptions

    CacheModule does not auto-apply interceptors, replace HTTP handlers, or provide cache decorators.
  3. Final Answer:

    Because CacheModule configures the cache store and TTL, enabling CacheInterceptor to function correctly. -> Option C
  4. Quick Check:

    CacheModule configures cache store and TTL for CacheInterceptor [OK]
Quick Trick: CacheModule setup is required for CacheInterceptor to work properly [OK]
Common Mistakes:
  • Thinking CacheModule auto-applies CacheInterceptor
  • Believing CacheModule replaces HTTP handlers
  • Assuming CacheModule provides caching decorators

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes