0
0
NestJSframework~10 mins

CacheModule setup in NestJS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import CacheModule in a NestJS module.

NestJS
import { Module, [1] } from '@nestjs/common';
import { CacheModule } from '@nestjs/cache-manager';

@Module({
  imports: [CacheModule.register()],
})
export class AppModule {}
Drag options to blanks, or click blank then click option'
ACacheModule
BInjectable
CController
DModule
Attempts:
3 left
💡 Hint
Common Mistakes
Importing CacheModule instead of Module
Forgetting to import any decorator
Importing Injectable or Controller by mistake
2fill in blank
medium

Complete the code to register CacheModule with a TTL of 5 seconds.

NestJS
CacheModule.register({ ttl: [1] })
Drag options to blanks, or click blank then click option'
A5
B5000
C60
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using milliseconds instead of seconds
Setting TTL to 0 which disables caching
Using a very large number unintentionally
3fill in blank
hard

Fix the error in the CacheModule import statement.

NestJS
import { CacheModule } from '[1]';
Drag options to blanks, or click blank then click option'
A@nestjs/common
Bcache-manager
C@nestjs/cache-manager
D@nestjs/cache
Attempts:
3 left
💡 Hint
Common Mistakes
Importing from @nestjs/common
Importing from a non-existent package
Using 'cache-manager' directly
4fill in blank
hard

Fill both blanks to configure CacheModule with a max cache size of 100 and TTL of 10 seconds.

NestJS
CacheModule.register({ ttl: [1], max: [2] })
Drag options to blanks, or click blank then click option'
A10
B100
C5
D50
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up TTL and max values
Using too large or zero values
Omitting one of the options
5fill in blank
hard

Fill all three blanks to import CacheModule, register it with TTL 20, and export it from the module.

NestJS
import { Module, [1] } from '@nestjs/common';
import { CacheModule } from '[2]';

@Module({
  imports: [CacheModule.register({ ttl: [3] })],
  exports: [CacheModule],
})
export class CacheConfigModule {}
Drag options to blanks, or click blank then click option'
AModule
B@nestjs/cache-manager
C20
DInjectable
Attempts:
3 left
💡 Hint
Common Mistakes
Importing wrong decorators
Wrong package for CacheModule
Setting TTL to string instead of number