Boostrapping
Initialize Redis client

Initialization

Initialization done by the static method CreateConnection of the RedisProvider
1
static CreateConnection(connectionConfig: IRedisConfig, connectionName: string): TRedisProvider;
Copied!

Basic

1
const redisProvider = RedisProvider.CreateConnection({
2
host: "127.0.0.1",
3
port: 6379,
4
isDefault: true
5
});
6
const resolvedClient = RedisProvider.getConnection();
7
expect(redisProvider).toBe(resolvedClient); // Should be truthy
Copied!

Using @sugoi/server

1
@ServerModule({
2
services: [
3
{
4
provide: RedisProvider.CreateConnection({
5
host: "127.0.0.1",
6
port: 6379,
7
isDefault: true
8
}),
9
useName: "RedisService"
10
}
11
]
12
})
13
export class BootstrapModule {
14
constructor(@Inject('RedisService') private _redisService: TRedisProvider) {
15
}
16
}
Copied!
Last modified 2yr ago