import { InjectRedis } from '@liaoliaots/nestjs-redis';
@
Injectable()
export class AppService {
constructor(@InjectRedis() private readonly redis: Redis) {}
getHello(): string {
return 'Hello World!';
}
async getRedisValue(key: string): Promise<string> {
const value = await this.redis.get(key);
return value;
}
async setRedis(key: string, value: string | Buffer | number) {
this.redis.set(key, value);
}
}
import { RedisModule } from '@liaoliaots/nestjs-redis';
RedisModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService) => ({
config: configService.get('redisConfig'),
}),
}),