.Net Framework 3.5 中是否包含 ObjectCache 类?
如果没有,是否有将对象存储在缓存中的替代方法(在 Windows 应用程序中而不是 asp.net 中)?
是否有人有任何在线资源或代码片段来演示如何使用 ObjectCache 类?
.Net Framework 3.5 中是否包含 ObjectCache 类?
如果没有,是否有将对象存储在缓存中的替代方法(在 Windows 应用程序中而不是 asp.net 中)?
是否有人有任何在线资源或代码片段来演示如何使用 ObjectCache 类?
.net framework 3.5中是否包含ObjectCache类
不。
如果您引用程序集,您仍然可以在 WinForms 应用程序中使用ASP.NET 缓存System.Web
:
HttpRuntime.Cache["key"] = "value";
如果您想定义更细粒度的属性:
HttpRuntime.Cache.Add(
"key",
"value",
null,
DateTime.MaxValue,
TimeSpan.FromSeconds(3),
CacheItemPriority.High,
new CacheItemRemovedCallback(OnItemRemove)
);
ObjectCache 是在 .NET 框架 4 中引入的。如果您使用的是以前的框架,则可以使用Microsoft Entreprise Library 缓存。
我不建议您使用 HttpRuntime.Cache,因为它不打算在 asp.net 应用程序之外使用。