我最近问了一个关于在ASP.NET MVC WebAPI应用程序中缓存应用程序数据的问题,这引出了一个新问题.ASP.NET中可用的不同缓存方法的优缺点是什么?
我来了:
内存缓存
http://msdn.microsoft.com/en-us/library/system.runtime.caching.memorycache.aspx
使用静态成员变量:
private static Northwind.SuppliersDataTable suppliers = null;
Run Code Online (Sandbox Code Playgroud)申请状态:
HttpContext.Current.Application["key"] ="Value"
Run Code Online (Sandbox Code Playgroud)数据缓存:
HttpRuntime.Cache.Insert(
/* key */ "key",
/* value */ "value",
/* dependencies */ null,
/* absoluteExpiration */ Cache.NoAbsoluteExpiration,
/* slidingExpiration */ Cache.NoSlidingExpiration,
/* priority */ CacheItemPriority.NotRemovable,
/* onRemoveCallback */ null);
Run Code Online (Sandbox Code Playgroud)我确信还有其他的,我知道它们都在技术上将数据存储在内存中......所以我知道应该使用什么来构建ASP.NET MVC webapi?
我以前的问题: 在内存中缓存应用程序数据:MVC Web API