nest-microservices-redis
v0.0.3
Published
A NestJS module for generator-nest-microservices yeoman template to handle redis features
Readme
nest-microservices-redis
- A NestJS module for
generator-nest-microservicesyeoman template for redis features
How to use
- install package with
npm i -S nest-microservices-redis - Register the
RedisModuleto your feature modules:
@Module({})
export class AppModule {
static register(config: ConfigOptions): DynamicModule {
return {
module: AppModule,
imports: [
RedisModule.register(config.redisOptions),
...
],
};
}
}- Once
RedisModuleis registered, then you can useRedisServiceto get/set keys from cache or use pub/sub
export class ExampleController {
constructor (private service: RedisService) {
super (service);
}
await get () {
this.redisService.get<any>('my-cached-stuff');
}
}Redis options
|Property|Type|Required|Description|
|-|-|-|-|
|appName|MessageQueueOptions|true| The channel name to be used for your pub/sub
|host|String|true| Host of your Redis server
|port|Number|true| Port used for your Redis server
