I am running integration tests against an Azure Redis Cache. This is my very straightforward cache implementation:
public class RedisCacheEngine : ICacheEngine
{
private static readonly Lazy<ConnectionMultiplexer> LazyConnection = new Lazy<ConnectionMultiplexer>(() =>
{
var config = new ConfigurationService();
var connectionString = config.Get("Redis.ConnectionString");
var connection = ConnectionMultiplexer.Connect(connectionString);
return connection;
});
private static ConnectionMultiplexer Connection => LazyConnection.Value;
public TValue Get<TValue>(string key) where TValue : class
{
var redisValue = Connection.GetDatabase().StringGet(key);
return redisValue == RedisValue.Null
? default(TValue)
: JsonConvert.DeserializeObject<TValue>(redisValue);
}
public void Set<TValue>(string key, TValue value) where TValue : class =>
Connection.GetDatabase().StringSet(key, JsonConvert.SerializeObject(value));
public void Remove(string key) => Connection.GetDatabase().KeyDelete(key);
}
When I look at the connection
object in the debugger, its failureMessage
field reads "SocketFailure on PING". I don't believe the server is timing out, as the timeout window is a generous five seconds and I'm on a fast system, with a fast connection.
The connection string is a standard Azure Redis Cache string, of the form
myapp.redis.cache.windows.net:6380,password=___,ssl=True,abortConnect=False
I have tried setting ssl = False, but without success.
I would ideally like to be able to run these tests on my build environment, but at the moment I can't retrieve a working connection. I can't see anything obvious that I may be missing in the documemtation. Are there any checks I can run to ensure I'm doing the right thing?