Kyle
Kyle
Jul 23, 2017 · 1 min read

Hey Ivo. Interesting solution, however I think you need to consider one big issue with this approach — you have no way to specify your connection information at the app level. Just passing createClient with no arguments creates a localhost connection at 6397 with no password. This creates at least two big issues:
1) First and foremost, you should *always* have a password on your Redis instance. It’s a major security issue to leave it unprotected.
2) As your app grows, you’re very likely to want to move your app and Redis layers on to different (virtual) machines.

You’re kind of stuck in your implementation on both of these fronts. You could specify this at your module level, but that’s not very portable. You might want to look into bringing the connection parameters either through environment variables or through an external file (external json is my preferred method — very configurable).

Another issue is that Redis is more than just a cache- you’re tightly coupling the connection with your caching layer. Later, if you want to use it as, say, a message broker, you’re going to need to create a new connection or rewrite this portion of your app to share.

    Kyle

    Written by

    Kyle

    Developer of things. Node.js + all the frontend jazz. Also, not from Stockholm, don’t do UX. Long story.