Reputation: 149
I can not connect to Azure Redis cache. I got an exception:An exception of type 'System.NullReferenceException' occurred in StackExchange.Redis.dll but was not handled in user code. I am kind of confused right now. Can I still use the pub/ sub functionality which is available when I connect to local host, Or azure redis cache is just for storage? I use the debugger and check the multiplexer isConnected property, the isConnected property is false.
static ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(ConfigurationManager.ConnectionStrings["Redis"].ToString());
IDatabase cache = redis.GetDatabase();
// Perform cache operations using the cache object...
// Simple put of integral data types into the cache
cache.StringSet("key1", "value");
cache.StringSet("key2", 25);
ISubscriber sub = redis.GetSubscriber();
const string channelName = "Transactions";
const string transTblName = "Transaction";
sub.Publish(channelName, transJson);
Upvotes: 4
Views: 1180
Reputation: 805
Looks like you need to change
ConfigurationManager.ConnectionStrings["Redis"].ToString()
To
ConfigurationManager.ConnectionStrings["Redis"].ConnectionString
Upvotes: 2