skip to Main Content

My question is very simple; should I create a redis instance the moment I need it, like inside a function, or create it once globally and reuse it?

2

Answers


  1. Better way is to create it once and inject it wherever you need it.

    Login or Signup to reply.
  2. Since you want lowest latency from Redis, you don’t want to depend on connection times but instead only round trip command processing times. It’s best to create a persistent connection then reuse that connection over a prolonged period of time to communicate with your Redis server.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search