I am trying to write records to a Redis cache. But sometimes I get the below exception,
I have no clue why I am getting this error
An error has occurred.","ExceptionMessage":"No connection is available to service this operation: SETEX token; SocketFailure on xxx.redis.cache.windows.net:6380/Subscription, origin: CheckForStaleConnection, input-buffer: 0, outstanding: 4, last-read: 1s ago, last-write: 0s ago, unanswered-write: 1s ago, keep-alive: 60s, pending: 0, state: ConnectedEstablishing, last-heartbeat: never, last-mbeat: -1s ago, global: 1s ago, mgr: RecordConnectionFailed_ReportFailure, err: never; IOCP: (Busy=0,Free=1000,Min=4,Max=1000), WORKER: (Busy=1,Free=8190,Min=4,Max=8191), Local-CPU: n/a","ExceptionType":"StackExchange.Redis.RedisConnectionException
My Connection Multiplexer
private static Lazy<ConnectionMultiplexer> lazyConnection = new Lazy<ConnectionMultiplexer>(() =>
{
return ConnectionMultiplexer.Connect(ConfigurationManager.AppSettings["RedisConString"]);
});
public static ConnectionMultiplexer Connection
{
get { return lazyConnection.Value; }
}
public bool Add(string key, string value, int expiryDays)
{
IDatabase cache = Connection.GetDatabase();
cache.StringSet(key, value, TimeSpan.FromDays(expiryDays));
return true;
}