#How to use and configure cache-manager-redis-yet?

4 messages · Page 1 of 1 (latest)

frank gorge
#

I am trying to configure redis-cache manager but it doesnt compile.

import type { RedisClientOptions } from 'redis';
import redisStore from 'cache-manager-redis-yet';

CacheModule.register<RedisClientOptions>({
  store: redisStore.redisStore,
  url: 'redis://localhost:6379/0',
}),

this gives " Cannot read properties of undefined (reading 'redisStore')"

to use only "redisStore" as written in official docs is not compiling.

#

Okay, I found something in the GitHub issues, which seems to work:

CacheModule.registerAsync({
  isGlobal: true,
  imports: [ConfigModule],
  useFactory: async (configService: ConfigService) => ({
    ttl: 60 * 60 * 24 * 7 * 1000, //configService.get('CACHE_TTL'),
    store: (await redisStore({
      url: 'redis://127.0.0.1:6379',
    })) as unknown as CacheStore,
  }),
  inject: [ConfigService],
}),
ivory furnace
cobalt turtle