c# - .net Windows 应用程序中的 ObjectCache

标签 c# .net windows-applications objectcache

.Net Framework 3.5 中是否包含 ObjectCache 类?

如果没有,是否有替代方法将对象存储在缓存中(在 Windows 应用程序中不是 asp.net)?

有没有人有任何在线资源或代码片段来演示如何使用 ObjectCache 类?

最佳答案

Is the ObjectCache class included in .net framework 3.5

没有。

您仍然可以使用 ASP.NET cache在 WinForms 应用程序中,如果您引用 System.Web 程序集:

HttpRuntime.Cache["key"] = "value";

如果您想定义更细粒度的属性:

HttpRuntime.Cache.Add(
    "key",
    "value", 
    null,
    DateTime.MaxValue,
    TimeSpan.FromSeconds(3),
    CacheItemPriority.High,
    new CacheItemRemovedCallback(OnItemRemove)
);

关于c# - .net Windows 应用程序中的 ObjectCache,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6758047/

相关文章:

c++ - 为进程输出问题设置编码

c# - 如何通过windows认证

c# - 如何使用 RegisterStartupScript 传递查询字符串?

c# - 在多线程应用程序中正确使用 IOC(装饰器或拦截器?)

.net - 3D 世界中最通用的轴方向是什么?

c# - Processcmdkey 中的可访问性不一致错误

XAML 设计器 System.Runtime.Remoting.RemotingException

c# - 从 RSS 提要中提取新项目

c# - .NET 相当于旧的 vb left(string, length) 函数

.net - 将 dll 部署到 GAC