我最近问了一个关于在ASP.NETMVC WebAPI应用程序中缓存应用程序数据的问题,它将我引向了一个新的问题.ASP.NET中提供的不同缓存方法的优缺点是什么?
我偶然发现:
-
内存缓存
http://msdn.microsoft.com/en-us/library/system.runtime.caching.memorycache.aspx
-
使用静态成员变量:
private static Northwind.SuppliersDataTable suppliers = null;
-
应用程序状态:
HttpContext.Current.Application["key"] ="Value"
-
数据缓存:
HttpRuntime.Cache.Insert( /* key */ "key", /* value */ "value", /* dependencies */ null, /* absoluteExpiration */ Cache.NoAbsoluteExpiration, /* slidingExpiration */ Cache.NoSlidingExpiration, /* priority */ CacheItemPriority.NotRemovable, /* onRemoveCallback */ null);
我相信还有其他的,而且我知道从技术上讲,它们都将数据存储在内存中……那么,你知道我应该为ASP.NETMVC webapi使用什么吗?