Selaa lähdekoodia

Don't lose Redis connection on reconnect

Keep Redis connection stored so that it's not lost and we avoid
reconnecting all the time.
Ossi Herrala 7 vuotta sitten
vanhempi
commit
c2eeb7ab73
1 muutettua tiedostoa jossa 2 lisäystä ja 1 poistoa
  1. 2 1
      worker/src/Worker/Program.cs

+ 2 - 1
worker/src/Worker/Program.cs

@@ -31,7 +31,8 @@ namespace Worker
                     // Reconnect redis if down
                     if (redisConn == null || !redisConn.IsConnected) {
                         Console.WriteLine("Reconnecting Redis");
-                        redis = OpenRedisConnection("redis").GetDatabase();
+                        redisConn = OpenRedisConnection("redis");
+                        redis = redisConn.GetDatabase();
                     }
                     string json = redis.ListLeftPopAsync("votes").Result;
                     if (json != null)