-
Notifications
You must be signed in to change notification settings - Fork 2k
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
RESTDataSource cache: Support for redis sentinel #1725
Comments
The easiest thing to do, if you need the feature now, would be to extend the class, overwriting the constructor of You would just need to duplicate some code from the exisiting redis-cache package there. I did this to use Google's Redis API with their client. |
Good idea. I will probably extend the class on my server, but do you think it would be good if we had an “apollo-cache-redis-sentinel” as part of apollo packages? |
It's hard to say. I think if it was consistently implemented, other packages would be convenient. The current redis package is pretty basic and hard coded (not a bad thing). It's a simple package and each implementation could be slightly different. For example, I use hashes With the current design, it would create a lot of duplicate code since everything in the constructor has to be copied, just to change the underlying client. It could take an option with an already instantiated I think the original intent was to have an easy enough API for export class RedisCache implements KeyValueCache {
constructor(options: Redis.ClientOpts) {
// Potentially could add an option to pass a client
const { client: userClient, ...opts } = options
const client = userClient || Redis.createClient(opts);
// promisify client calls for convenience
client.mget = promisify(client.mget).bind(client);
client.set = promisify(client.set).bind(client);
client.flushdb = promisify(client.flushdb).bind(client);
client.quit = promisify(client.quit).bind(client);
this.client = client;
this.loader = new DataLoader(keys => this.client.mget(keys), {
cache: false,
});
} |
Just created a PR #1770 with an implementation for that. Maybe we can discuss on top of that. |
Happy to re-open if this isn't resolved with #1770, but I hope that did the trick! :) |
Hey guys,
As far as I know, apollo-server supports caching on redis, in memory or memcached.
apollo-server-cache-redis
uses npm'sredis
module in order to create a redis client.The
redis
module does not currently support redis sentinel, as per some issues like redis/node-redis#302I am opening this issue so we can discuss how to support redis sentinels on RESTDataSource caching.
So, should we create a new package like
apollo-server-cache-redis-sentinel
? Or, should we support sentinels on the existingapollo-server-cache-redis
? Or, should the client usingApolloServer
be responsible for creating a newKeyValueCache
implementation that supports sentinels?Thanks in advance!
The text was updated successfully, but these errors were encountered: