Skip to content

Commit

Permalink
Don't lose Redis connection on reconnect
Browse files Browse the repository at this point in the history
Keep Redis connection stored so that it's not lost and we avoid
reconnecting all the time.
  • Loading branch information
oherrala committed Oct 1, 2017
1 parent a58579e commit c2eeb7a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion worker/src/Worker/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public static int Main(string[] args)
// 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)
Expand Down

0 comments on commit c2eeb7a

Please sign in to comment.