-
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
apollo-server-cache-redis: Add redis connection uri interface to RedisCache #5006
Comments
Hi! Rather than continuing down the road of making our package's API even more tightly coupled to the constructor API of |
- Allow Redis client to be injected by using the `BaseRedisCache` class which contains the existing implementation logic without the client initialisation. - Removes duplication between `RedisCache` and `RedisClusterCache` - Fixes a bug where the result of delete is returned as a number, rather than a boolean. (Our TypeScript types have always declared that this function returns a boolean as `KeyValueCache.delete` should, but the actual implementation returned a number. This was not noticed because of the use of an `any` type.) In my opinion, `BaseRedisCache` should really be `RedisCache` and the existing `RedisCache` + `RedisCacheCluster` should either be renamed to identify that they are using the ioredis client, or removed and left for the consumer of the library to implement/ inject the client using this method. But this would obviously be a breaking change so maybe one to think about for the future? I've created an interface for the `RedisClient` rather than rely on the ioredis type as i do not believe apollo should be tied to the ioredis interface. Fixes #4871. Fixes #4870. Fixes #5006.
I've released a prerelease with this fix ( |
This has been released in |
RedisCache
currently only acceptRedisOptions
interface ofioredis
, butRedis
constructor ofioredis
can accept more variadic arguments.https://github.com/luin/ioredis#connect-to-redis
In my use case, my application already connect to redis via connection uri
redis://...
, andRedisCache
also want to connect its redis, butRedisCache
can't accept connection uri.The text was updated successfully, but these errors were encountered: