Complete the code to import the CacheModule in a NestJS module.
import { CacheModule } from '@nestjs/cache-manager'; @Module({ imports: [CacheModule.[1]()], }) export class AppModule {}
Use CacheModule.register() to set up the cache module with default options.
Complete the code to set up Redis as the cache store in NestJS.
CacheModule.register({
store: [1],
host: 'localhost',
port: 6379,
}),Use redisStore imported from cache-manager-redis-store as the Redis cache store.
Fix the error in the code to inject Cache correctly in a NestJS service.
constructor(private readonly cache: [1]) {}The correct injection type is Cache to access cache methods.
Fill both blanks to create a cache key with a prefix and set a TTL of 5 minutes.
await this.cache.[1]('user:123', userData, { ttl: [2] });
Use set to store data with a TTL of 300 seconds (5 minutes).
Fill all three blanks to configure CacheModule with Redis store, host, and port.
CacheModule.register({
store: [1],
host: [2],
port: [3],
}),Use redisStore for Redis, host as 'localhost', and port 6379.
