Reputation:
I want to have more than one Redis client object as multiple DB instance like DB0 (O INDEX REDIS DB). Currently, I'm using
let RedisClient = require("./redis");
RedisClient.select(1, function (err, res) {
// any operation here
});
so RedisClient
is having DB1 instance. what is the best way to deal with multiple db if we want to use another DB2 ?
Upvotes: 1
Views: 1510
Reputation: 2531
Use redis.createClient()
twice
const redis = require("redis");
const client_1 = redis.createClient(REDIS_1_HOST, REDIS_PORT_1);
const client_2 = redis.createClient(REDIS_2_HOST, REDIS_PORT_2);
see: https://www.npmjs.com/package/redis#rediscreateclient
Upvotes: 2