我无法连接到Azure Redis缓存。我有一个例外:StackExchange.Redis.dll中发生了类型'System.NullReferenceException'的异常,但未在用户代码中处理。我现在有点困惑。我是否仍然可以使用连接到本地主机时可用的pub / sub功能,或者azure redis缓存仅用于存储?我使用调试器并检查多路复用器isConnected属性,isConnected属性为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);
答案 0 :(得分:2)
看起来你需要改变
ConfigurationManager.ConnectionStrings["Redis"].ToString()
要
ConfigurationManager.ConnectionStrings["Redis"].ConnectionString