How can I use System.Web.Caching.Cache in a Console application?

后端 未结 6 721
死守一世寂寞
死守一世寂寞 2021-02-01 03:47

Context: .Net 3.5, C#
I\'d like to have caching mechanism in my Console application.
Instead of re-inventing the wheel, I\'d like to use System.Web.Caching.Cache

6条回答
  •  天命终不由人
    2021-02-01 03:58

    The System.Web.Caching.Cache class relies on having its member "_cacheInternal" set by the HttpRuntime object.

    To use the System.Web.Caching classes you'd have to create an HttpRuntime object and setup the HttpRuntime.Cache property. You'd effectively have to emulate IIS.

    You're better off using other caching frameworks like:

    • Caching Application Block
    • Spring.net
    • NCache

提交回复
热议问题