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

feat: enable injection of redis client into redis cache #4871

Closed
wants to merge 4 commits into from

Conversation

RichardWright
Copy link

Feat: enable injection of redis client. Stops multiple clients being invocated.

@Nedomas
Copy link

Nedomas commented Feb 19, 2021

Also need this. Anything we could do to move this forward?

@RichardWright
Copy link
Author

I've done everything I think I can, just need some attention from the maintenance people

@glasser
Copy link
Member

glasser commented Feb 23, 2021

This seems like a reasonable thing to want to do — in fact, it would be better to just have designed this as taking a client in the first place rather than being responsible for initializing a third-party library.

I'm not a big fan of the API in this change though... two arguments and you have to pass exactly one non-null. It would be good to just have two entry points, one for "here's the client" and one for "please make a client for me".

Ideally, "here's the client" would be the constructor and "please make a client for me" would be a (not particularly useful) factory function. But if we want to be backwards-compatible with the existing API, that's tough (since factory functions to have to go through the single constructor).

What if we just create a new class, RedisClientCache (or maybe a better name exists), which takes a client as its argument? Then the old RedisCache can just be a subclass with a different constructor.

While you're at it, it looks like RedisClusterCache is basically a copy-and-paste of RedisCache that mostly just differs in the constructor, so I bet you could reduce the duplication here by making the two existing classes into small wrappers around the new class.

Please also make sure there is test coverage of the new API.

@RichardWright
Copy link
Author

RichardWright commented Feb 24, 2021

I'm really not into refactoring other people's code bases. Ideally I would make a change and people with better knowledge and ideas about the design would refactor how they envisage it. Otherwise you'll never accept my pr

@glasser
Copy link
Member

glasser commented Feb 24, 2021

Isn't that the process that's happening? You made a change and my suggestion is that instead of complicating the constructor of the existing classes, you make a new class with a simple constructor.

You're welcome to take that suggestion or wait for somebody else to do so. As a maintainer, my approach to packages like this one that exist to interface with external projects like Redis is that improvements should be driven and QA'd by folks who actually run Redis themselves. We don't use this package ourselves at Apollo so I don't feel like we are able to complete this PR ourselves.

@glasser glasser closed this in 1a7f470 Apr 6, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants