Hiya, so I have a service class that looks sort of like this (Minimized to only the important bits):
import type { EventEmitter2 } from '@nestjs/event-emitter';
import type { Cache } from 'cache-manager';
import type { RedisClient } from 'bullmq';
import { CACHE_MANAGER } from '@nestjs/cache-manager';
@Injectable()
export class GameEventStreamService {
private readonly logger = new Logger(GameEventStreamService.name);
private cache: RedisClient;
constructor(
@Inject(CACHE_MANAGER) private cacheManager: Cache,
private eventEmitter: EventEmitter2,
) {
cacheManager.stores
.at(0)
.store.getClient()
.then((client) => {
this.cache = client;
});
}
//...\\
}
And later down the line, when I try to use the this.cache, it returns null/undefined. Why?