Skip to content

Commit c2eeb7a

Browse files
committed
Don't lose Redis connection on reconnect
Keep Redis connection stored so that it's not lost and we avoid reconnecting all the time.
1 parent a58579e commit c2eeb7a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

worker/src/Worker/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public static int Main(string[] args)
3131
// Reconnect redis if down
3232
if (redisConn == null || !redisConn.IsConnected) {
3333
Console.WriteLine("Reconnecting Redis");
34-
redis = OpenRedisConnection("redis").GetDatabase();
34+
redisConn = OpenRedisConnection("redis");
35+
redis = redisConn.GetDatabase();
3536
}
3637
string json = redis.ListLeftPopAsync("votes").Result;
3738
if (json != null)

0 commit comments

Comments
 (0)