我有这个解决redis的工厂:
import {RedisClient} from "redis";
export const RedisProvider = {
provide: 'RedisToken',
useFactory: async () => {
return new Promise((resolve, reject) => {
let redisClient = new RedisClient({
host: 'resolver_redis'
});
redisClient.on('ready', async function () {
let campaigns = await redisClient.get('campaigns');
if ( ! campaigns) {
// Note: "client" is not available in this scope
client.send('get:campaigns').subscribe(async function (campaigns) {
await redisClient.set('campaigns', campaigns);
resolve(redisClient);
});
}
else {
resolve(redisClient);
}
});
});
}
};
但除此之外,我想检查redis中是否存在特定的密钥,如果不是我想使用微服务来检索它,但为此我需要注入微服务"客户端",我想把它改成那样的东西:
(desiredGrade != 'A' && desiredGrade != 'B' && desiredGrade != 'C')
唯一的问题是我无法访问"客户端"或者我? 如果它更有意义,它也可以是另一个提供者,但是我还需要优先加载提供者,我这样做是因为应用程序需要这些数据用于启动的东西