Bird
0
0

What will be the output if you forget to import CacheModule but apply CacheInterceptor globally?

medium📝 component behavior Q5 of 15
NestJS - Interceptors
What will be the output if you forget to import CacheModule but apply CacheInterceptor globally?
AThe application logs a warning but caches responses anyway.
BThe CacheInterceptor silently disables caching and works normally.
CThe application throws a runtime error because cache manager is not available.
DThe CacheInterceptor caches data in memory by default without errors.
Step-by-Step Solution
Solution:
  1. Step 1: Recognize CacheModule role

    CacheModule provides the cache manager needed by CacheInterceptor to store data.
  2. Step 2: Consequence of missing CacheModule

    Without CacheModule, CacheInterceptor cannot function and causes runtime errors.
  3. Final Answer:

    The application throws a runtime error because cache manager is not available. -> Option C
  4. Quick Check:

    CacheModule missing = runtime error with CacheInterceptor [OK]
Quick Trick: Always import CacheModule before using CacheInterceptor [OK]
Common Mistakes:
  • Assuming CacheInterceptor works without CacheModule
  • Expecting silent fallback without errors
  • Confusing CacheModule with other modules

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes