-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add support for ioredis #12
Conversation
@@ -76,7 +76,7 @@ Limiter.prototype.get = function (fn) { | |||
if (err) return fn(err); | |||
// If the request has failed, it means the values already | |||
// exist in which case we need to get the latest values. | |||
if (!res || !res[0]) return mget(); | |||
if (!res || !res[0] || !res[0][1]) return mget(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only problem that I see is that you rely on the fact that node_redis returns a string result.
I think that a better way would be to check if res[0] is an array, if so, check if res[0][1] exists.
what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm...yes, it would make more sense. Just submitted a commit for this.
I really like this PR and want to merge it, just one more question, don't you want to check the response also for the |
Yes, of course. Didn't notice there's another |
thanks! |
Hi, I'm the author of ioredis, a node.js redis client that supports Sentinel and Cluster.
I'm using this awesome module in my application, however this module doesn't support ioredis, which means I can't use it with my sentinel servers.
It's trivial to support ioredis since it's compatible with node_redis for most APIs. The only difference is the result of multi in ioredis is
[[err1, res1], [err2, res2], [err3, res3]]
and in node_redis is[res1, res2, res3]
. Refer to https://github.com/luin/ioredis/wiki/Migrating-from-node_redis for more details.The only change have to be made is changing
(!res || !res[0])
to(!res || !res[0] || !res[0][1])
, which works with both node_redis and ioredis. What's more, I addedforEach
wrapper around the original tests so that it will test this module against both node_redis and ioredis.