First of all, thanks for this library. It is much appreciated. Good work. :)
I ran into an issue yesterday and I managed to narrow it down to the way the createClient method works within AsyncRedis.
It seems that the method will not create two distinct client instances with the same configuration - as opposed to what the base Redis method implementation would. Instead, it keeps track of created clients and stores them in an internal array, so that a the same instance will be returned when equivalent options are a match.
I'm not sure why it was designed that way. There may be a very valid reason I'm simply unaware of. In any case, this is a problem for situations in which you do need two distinct clients on the same database, such as when one acts as a subscriber and the other as a publisher. You'd be calling createClient method twice on two distinct variables and use them as pub/sub pattern dictates; still, the code would fail at runtime with the following error message:
ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context
The workaround I came up with was to create clients out of base Redis library, then use AsyncRedis.decorate on them. Works like a charm and still allows using promises.
If pooling of client instances really is the intended design for createClient, then I suggest documenting the method accordingly.
Hi,
First of all, thanks for this library. It is much appreciated. Good work. :)
I ran into an issue yesterday and I managed to narrow it down to the way the
createClient
method works withinAsyncRedis
.It seems that the method will not create two distinct client instances with the same configuration - as opposed to what the base
Redis
method implementation would. Instead, it keeps track of created clients and stores them in an internal array, so that a the same instance will be returned when equivalent options are a match.I'm not sure why it was designed that way. There may be a very valid reason I'm simply unaware of. In any case, this is a problem for situations in which you do need two distinct clients on the same database, such as when one acts as a subscriber and the other as a publisher. You'd be calling
createClient
method twice on two distinct variables and use them as pub/sub pattern dictates; still, the code would fail at runtime with the following error message:The workaround I came up with was to create clients out of base
Redis
library, then useAsyncRedis.decorate
on them. Works like a charm and still allows using promises.If pooling of client instances really is the intended design for
createClient
, then I suggest documenting the method accordingly.Thanks! :)