Closed prkirby closed 2 years ago
I think it might be better to just let the users pass the Redis client instance to the cache. There are still much more options for initializing Redis that we can't cover in this kind of interface.
export interface CacheOptions {
uri?: string
redis?: Redis.Redis | Redis.Cluster
ttl?: number
tbd?: number
}
Good call, let me make whip that up quick.
@rjyo Ok that should be all set, let me know if theres anything else that needs clean up.
@rjyo Do you think this is something that could get merged? Our team needs this feature for a release we are hoping to make in the near future.
@rjyo If it's all good can we go ahead with merging this?
Added in Flatted as I was getting Circular JSON Error when using this code in my repo, due to init() in adapter.ts calling JSON.stringify() on options. Since passing in a Redis instance is a circular object, this was throwing UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON
@rjyo Do you think this can be merged ?
@rjyo do you have some time to look at this? For now we're using npm-patch-package to have this up and running but we don't want to hit product with monkey patched npm package. Would be great if we can close this one.
@rjyo let me know if there is anything you want changed / updated.
Sorry for being late on this issue. I actually can't get the test running in the pipeline.
@rjyo For the test, you need to have a redis instance that supports clustering. Here is the Docker container that I used locally, not sure if that will help: https://github.com/Grokzen/docker-redis-cluster
Add support for passing an ioredis cluster config object to Cache constructor
Update count function to use a promise array instead of mget as mget is not supported for clusters when keys are stored in different slots
For testing purposes, you can use this docker container for a redis cluster: https://github.com/Grokzen/docker-redis-cluster