【发布时间】:2016-08-25 13:23:12
【问题描述】:
[Azure Redis 缓存]
ConnectionMultiplexer connection = ConnectionMultiplexer.Connect(string.Format("{0},abortConnect=false,ssl=true,password={1}", "reditCacheEndpoint", "reditCachePassword"));
IDatabase cache = connection.GetDatabase();
cache.StringSet("time", DateTime.Now, TimeSpan.FromMinutes(30));
优点
可用于 Azure 中的所有程序
不影响应用程序的性能
缺点
贵
慢
[应用缓存]
System.Web.HttpContext.Current.Cache["time"] = DateTime.Now;
优点
更快
免费
缺点
只能在您当前的应用中使用
影响应用程序的性能
我真的不明白为什么应该使用 Azure Redis 缓存而不是应用程序缓存。
如果由于缓存占用过多资源而导致性能出现问题,您可以随时为您的应用添加更多功能,而不是扩大缓存,那样会更昂贵。
当您需要将 Azure Redis 缓存用于一项以上的服务时,它是不错的选择,但大多数情况下,我只需要为一项服务进行缓存。
为什么要使用 Azure Redis 缓存?
如果您觉得我忘记了一些重要的事情,请补充更多优点和缺点。
【问题讨论】:
-
我认为更重要的原因是,如果您正在规划应用程序的可扩展性。
标签: asp.net-mvc azure caching