Skip to content
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

Include a default redis client #203

Open
nfriedly opened this issue Feb 20, 2024 · 3 comments
Open

Include a default redis client #203

nfriedly opened this issue Feb 20, 2024 · 3 comments

Comments

@nfriedly
Copy link
Member

nfriedly commented Feb 20, 2024

Description

I think we should include a default redis client, and accept a new option for the connection details that is passed directly to the redis client.

I think node-redis and ioredis are the two most popular ones. node-redis has more github stars while ioredis has more npm downloads. I'm leaning a bit towards ioredis since it has a smaller file size, although node-redis has the advantage of only accepting 0 or 1 arguments to it's constructor, whereas ioredis accepts 0-3. (We could accept an array for the 2+ arg versions.)

We should still keep the sendCommand option around for backwards compatibility and advanced usage. It should probably throw an error if both sendCommand and our new option are set at the same time.

Why

Alternatives

Not changing anything

@gamemaker1
Copy link
Member

I'm on the fence for this one; don't really see a need to add this option. We can fix #202 by explaining the sendCommand function better in the documentation.

However, if we do implement this, I think we should go with ioredis.

@moohbr
Copy link

moohbr commented Jun 9, 2024

Apologies for the delayed response (university problems), but after spending some time troubleshooting...

The developers can't simply replicate the solution from rate-limit-mongo (#202) because in this solution the team tailored a MongoDB client specifically for this purpose. Therefore, if we aim to achieve similar functionality, we need to rely on a single Redis client, this might deviate from the original approach.

So, I believe that have two sides:

1st side:

  • Add the documentation in the method sendCommand explain that may override.
    image

  • Add a default client like ioredis .

2nd side (and I prefer it):

  • Deprecate the method sendCommand and use, if possible, the pure default Redis client (or yours prefers) for it.

I believe that using the default Redis client can be more transparent for users, avoiding adding a lot of dependencies to their projects.

@nfriedly
Copy link
Member Author

nfriedly commented Jun 10, 2024

No worries.

The trouble is that I'd like to avoid a breaking change unless it's really necessary. I also think there are some more advanced use-cases where being able to provide a custom sendCommand is still valuable. So I don't really want to get rid of that option. I just want to make basic usage easier.

I'm ok with either node-redis or ioredis as the built-in client, because the folks who care will still have the option of using their own via sendCommand.

Improving the documentation is always good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants