在redis helper方法中,我维护了2个Redis连接字符串。一个用于local
,另一个用于Azure redis server
。每次我需要发布时,我必须手动更改。我的应用程序是ASP.net MVC(SPA)应用程序。
问:那么在Azure门户网站上或在我发布时,是否有任何地方可以设置已发布的Redis connection string
?
public class RedisConnectorHelper
{
private static readonly Lazy<ConnectionMultiplexer> LazyConnection =
new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect("localhost,ConnectTimeout=10000"));//local host
//private static readonly Lazy<ConnectionMultiplexer> LazyConnection =
// new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect("Myredis.redis.cache.windows.net:6380,password=mypassword,ssl=True,abortConnect=False"));//production
}
更新:
我已在web.config.release
文件中设置了该文件,如下所示。
<connectionStrings>
<add name="Abp.Redis.Cache" connectionString="Myredis.redis.cache.windows.net:6380,password=mypassword=,ssl=True,abortConnect=False" />
</connectionStrings>
但似乎没有把它拿起来。你能告诉我为什么吗?
答案 0 :(得分:0)
这是诀窍。欢呼:)
#if DEBUG
private static readonly Lazy<ConnectionMultiplexer> LazyConnection =
new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect("localhost,ConnectTimeout=10000"));//local host
#else
private static readonly Lazy<ConnectionMultiplexer> LazyConnection =
new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect("Myredis.redis.cache.windows.net:6380,password=mypassword,ssl=True,abortConnect=False"));//production
#endif