Search code examples
cachingazureredistimeoutexceptionstackexchange.redis

TimeoutException during setting cache in StackExchange.Redis


I am trying to set key-value pairs in Azure Redis cache using StackExchange.Redis client in Visual Studio. This is the code I have:

ConnectionMultiplexer connection=ConnectionMultiplexer.Connect("connection_name,ssl=true,password=some_password");

IDatabase cache = connection.GetDatabase();      
for (int i = 0; i < 500; i++)
{
cache.StringSet("key" + i, "value" + i);
}

However, I get TimeoutException while the code is setting some random key value pair. What could be the issue and how should I resolve it? Thanks.


Solution

    • could be a server stall ("slowlog get" and the Redis server logs are the first things to look at)
    • could be a network infrastructure stall
    • could be a library glitch
    • could just be blocked on data (perhaps try a slightly higher timeout)

    The error message should include a bunch of numbers. If you can tell me those numbers, I might be able to say more.