难道我们不应该在一个WinForms应用程序使用的System.Web.Caching.Cache类? [英] Should we not use the System.Web.Caching.Cache class in a WinForms app?

查看:95
本文介绍了难道我们不应该在一个WinForms应用程序使用的System.Web.Caching.Cache类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了几篇文章/博客文章是主张用的System.Web.Caching.Cache的是没有为Web应用程序,但是,的 MSDN文档相当明确指出,

I've seen several articles/blog posts that advocate the use of the System.Web.Caching.Cache in applications that are not for the Web, however, the MSDN documentation quite clearly states that

Cache类不适合使用ASP.NET应用程序之外。在设计和测试中使用ASP.NET提供的缓存为Web应用程序。在其他类型的应用程序,如控制台应用程序或Windows窗体应用程序,ASP.NET缓存可能无法正常工作。

The Cache class is not intended for use outside of ASP.NET applications. It was designed and tested for use in ASP.NET to provide caching for Web applications. In other types of applications, such as console applications or Windows Forms applications, ASP.NET caching might not work correctly.

时的文件错了,还是应该我们真的不使用这个类呢?如果是后者,有什么可以去错了吗?我们的平台是的WinForms / .NET 3.5。

Is the documentation wrong, or should we really not be using this class? If the latter, what could go wrong? Our platform is Winforms/.NET 3.5.

推荐答案

过期或不使用缓存对象不能被自动如果应用程序是不是一个ASP.NET应用程序中删除。因此,如果高速缓存对象ASP.NET外使用,系统存储器被保留用于缓存对象不会被释放。您无法手动调用内部ASP.NET方法来清除缓存,因为这些方法被标记为内部和预期供内部使用。因此,它的决定,需要您自担风险使用它的外部应用程序。 的System.Web.Caching.Cache对象

Expired or unused Cache objects cannot be automatically removed if the application is not an ASP.NET application. Therefore, if Cache objects are used outside ASP.NET, the system memory that is reserved for the Cache objects is not released. You cannot manually invoke the internal ASP.NET methods to clean up the cache because the methods are marked as internal and intended for internal use. So its your decision to use it in an outside application at your own risk. System.Web.Caching.Cache object

斯科特Hanselman有一个文章张贴于它的更多信息

Scott Hanselman has a article post on it for more details

这篇关于难道我们不应该在一个WinForms应用程序使用的System.Web.Caching.Cache类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆