.Net 4内存缓存类和用户会话 [英] .Net 4 Memory Cache class and user Session
问题描述
中的新类 MemoryCache . Net 4.0看起来就像asp.net缓存一样.我的问题是:
The new class MemoryCache in .Net 4.0 appears to act just like asp.net caching. My questions are:
MemoryCache等同于在Session Cache中为用户存储对象/值,但不存储在aspx页面后面的代码中.
Is MemoryCache equivalent to storing an object/value in for a user in Session Cache, but not in the code behind of an aspx page.
服务器上存在的存储在MemoryCache中的值可以访问网页事件吗?
Can a value stored in MemoryCache, which exists on the server, be accessable to a web page event?
推荐答案
MemoryCache等同于在会话缓存中为用户存储对象/值
Is MemoryCache equivalent to storing an object/value in for a user in Session Cache
不,它不是等效的. ASP.NET会话对象是按用户键/值存储,而MemoryCache是应用程序级键/值存储(值在所有用户之间共享).
No, it is not equivalent. The ASP.NET Session object is per user key/value storage, whereas MemoryCache is an application level key/value storage (values are shared among all users).
是否可以将存储在服务器上的MemoryCache中存储的值设置为 可访问网页事件?
Can a value stored in MemoryCache, which exists on the server, be accessable to a web page event?
在ASP.NET MVC中,通常没有网页事件,但是您可以访问应用程序中各处存储在MemoryCache中的值.
In ASP.NET MVC there are usually no web page events but you can access values stored in MemoryCache everywhere within the application.
基本上,在ASP.NET应用程序中,新的MemoryCache
对象只是旧的HttpContext.Cache
对象的包装器(它将值存储在旧的Cache对象中).
Basically, in an ASP.NET application, the new MemoryCache
object is just a wrapper for the old HttpContext.Cache
object (it stores values in the old Cache object).
这篇关于.Net 4内存缓存类和用户会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!