I’m using NestJS 10.0.0, with @nestjs/cache-manager
=2.2.2 and cache-manager
=5.5.2 and cache-manager-redis-yet
=5.0.0. However, as the title says, I’m encountering an issue where I can’t make it instantiate inside any service, even though I’ve set global parameter for CacheModule
.
Here’s some simple example:
app.module.ts:
import { CacheModule } from "@nestjs/cache-manager";
import { redisStore } from "cache-manager-redis-yet";
import { RedisClientOptions } from "redis";
import { RedisModule } from "./redis.module.ts";
@Module({
providers: [GenericSeederService],
imports: [
CacheModule.register<RedisClientOptions>({
isGlobal: true,
store: redisStore,
url: process.env.REDIS_URL,
}),
RedisModule,
],
})
export class AppModule {}
redis.module.ts:
import { RedisService } from './redis.service';
@Module({
providers: [RedisService],
exports: [RedisService],
})
export class RedisModule {}
redis.service.ts:
import { CACHE_MANAGER } from "@nestjs/cache-manager";
import { RedisCache } from "cache-manager-redis-yet";
export class RedisService {
constructor(
@Inject(CACHE_MANAGER)
private readonly cacheManager: RedisCache
) {}
private async getKeysFromKeySet(keySet: string): Promise<string[]> {
const keys: string[] = await this.cacheManager.store.client.sMembers(keySet);
return keys;
}
}
And I get this error:
[Nest] 251 - 05/12/2024, 3:38:26 AM ERROR [ExceptionHandler] Nest can't resolve dependencies of the RedisService (?). Please make sure that the argument Object at index [0] is available in the RedisService context.
I can’t understand why this happens.