-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
createClient method not always behaving as expected #60
Comments
+1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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! :)
The text was updated successfully, but these errors were encountered: