Feat(medusa): Replace redis with ioredis + redis_options config module #2437
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Use only one Redis client (
ioredis
) inmedusa
package instead of havingioredis
+redis
simultaneously.Add also a
redis_options
field in the project config module to easily configure advanced options for Redis.Why
When deploying Medusa in production with Redis, I encountered the problem that Redis clients doesn't work well by default with IPv6 addresses.
redis/ioredis#1576
redis/node-redis#1550
Medusa being on top of theses clients, we need to be able to configure it while staying backward compatible.
How
Replaced
redis
used inloaders/express.ts
withioredis
. connect-redis used to store Express session is compatible with both clients. Maybe I'm missing an historic issue with the choice of double Redis clients.Add second argument for all
new Redis
withredis_options
(typed with the interfaceRedisOptions
fromioredis
now that we have only one client). If no defined, will do nothing so backward compatible.Example:
Testing
Don't know exactly how to test it in a proper way. I used patch-package on my project to have the changes working. Any suggestions welcomed :)