nestjs / nestjs.com

The official website https://nestjs.com 🏆
https://nestjs.com
MIT License
137 stars 23 forks source link

Wrong redisStore cache documentation #68

Closed rcmarc closed 2 years ago

rcmarc commented 2 years ago

In the docs, it says that a redis store on the CacheModule must be set up like this:

@Module({
  imports: [
    CacheModule.register<RedisClientOptions>({
      store: redisStore,

      // Store-specific configuration:
      socket: {
        host: 'localhost',
        port: 6379,
      },
      isGlobal: true
    }),
  ],
  controllers: [AppController],
})

but when the service is manually injected:

constructor(@Inject(CACHE_MANAGER) private cacheManager: Cache) {}

it gives an instance of the In Memory Cache

I think this is a documentation issue because when i set up the CacheModule in this way without the socket object:

@Module({
  imports: [
    CacheModule.register({
      store: redisStore,
      host: 'localhost',
      port: 6379,
      isGlobal: true
    }),
  ],
  controllers: [AppController],
})

it works as expected.

This issue was reproduced with this environment:

kamilmysliwiec commented 2 years ago

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.