Don't lose Redis connection on reconnect
Keep Redis connection stored so that it's not lost and we avoid reconnecting all the time.
This commit is contained in:
parent
a58579e442
commit
c2eeb7ab73
@ -31,7 +31,8 @@ namespace Worker
|
|||||||
// Reconnect redis if down
|
// Reconnect redis if down
|
||||||
if (redisConn == null || !redisConn.IsConnected) {
|
if (redisConn == null || !redisConn.IsConnected) {
|
||||||
Console.WriteLine("Reconnecting Redis");
|
Console.WriteLine("Reconnecting Redis");
|
||||||
redis = OpenRedisConnection("redis").GetDatabase();
|
redisConn = OpenRedisConnection("redis");
|
||||||
|
redis = redisConn.GetDatabase();
|
||||||
}
|
}
|
||||||
string json = redis.ListLeftPopAsync("votes").Result;
|
string json = redis.ListLeftPopAsync("votes").Result;
|
||||||
if (json != null)
|
if (json != null)
|
||||||
|
Loading…
Reference in New Issue
Block a user