mcollina / mqemitter-redis

Redis-powered MQEmitter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use a shared ioredis instance

leobudima opened this issue · comments

Hi,

I'm using Redis in a couple of places in my app for different purposes, and would like to try and use a shared ioredis instance between them, instead of each part of code creating its own connections to Redis. I see that mqemmiter-redis does not support passing an existing ioredis instance, but also that it creates 2 separate connections for pub & sub. I was wondering if there's a particular reason why this is better?

If not, would you be interested in accepting a PR that adds an option for passing an ioredis instance? Very simple, along the lines of:

this.subConn = opts.ioredisInstance || new Redis(opts);

Thanks!

Unfortunately it’s not possible. When running a subscription command it’s not possible to run any other command on top of a connection.