Multi-Client & Sentinel Redis Setup with NestJS
Setup Multi-Sentinel Multi-client Redis connections with NestJS Server

Search for a command to run...
Setup Multi-Sentinel Multi-client Redis connections with NestJS Server

No comments yet. Be the first to comment.
TL;DR, it's a cultural and artistic movement that envisions a sustainable and equitable future.

Builds on Netlify not working as expected? Check if your build depends on dotfiles

If you are here to read The Nibble, they are now published at https://nibbles.dev
Back to Monoliths, the MOAT memes, Hello Mojo!, Wallace Line, Fake traps on Maps, Shape-E, Reflect, Zuck winning Jiu-Jitsu Medals, make GPT a TLD?

GAuth can do cloud sync, why finetune? when you can build LLM, track object in video, Opera makes a comeback and more

There's already a package out there nestjs-redis, it is a wrapper around ioredis and quite easy to use.
There is only one issue you'll face with the package is while wrapping over ioredis the devs kept the key name for the sentinel name and the same name is used for client/connection name as per the implementation of the parent package.
I have fixed the same issue in forked repo.
The example config to connect to multi-sentinel name-based setup is below:
[
{
"clientName": "sentinelDB5",
"sentinels": [
{
"host": "localhost",
"port": 6380
},
{
"host": "localhost",
"port": 6381
}
],
"db": 5,
"name": "hahaCluster",
"password": "topSecret"
}
]
After connecting with this config you can call the following in your services to get clients for these sentinels
const client = await this.redisService.getClient('sentinelDB5');
That's all, now you can go back to hacking as usual ๐๐ป