缓存的优势VS会议 [英] Advantages of Cache vs Session

查看:124
本文介绍了缓存的优势VS会议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是存储会话的DataTable VS缓存之间的区别?有哪些优势和劣势?

What is the difference between storing a datatable in Session vs Cache? What are the advantages and disadvantages?

所以,如果它是一个简单的搜索页面它返回一个DataTable结果并将其绑定到一个gridview。如果用户的一个搜索和用户B的搜索,是它更好地将其存储在会话,因为每个用户最有可能有不同的结果,或者我还可以保存他们的每一个在高速缓存搜索,或因为有这是否没有意义只有一个高速缓存。我想基本上是我想说的是,将缓存被覆盖。

So, if it is a simple search page which returns result in a datatable and binds it to a gridview. If user 'a' searches and user 'b' searches, is it better to store it in Session since each user would most likely have different results or can I still store each of their searches in Cache or does that not make sense since there is only one cache. I guess basically what I am trying to say is that would the Cache be overwritten.

推荐答案

一个重要区别是,缓存中的项目可以在指定的时间量之后期满(从缓存中删除)。项目投入会议将呆在那里,直到会话结束。

One important difference is, that items in the cache can expire (will be removed from cache) after a specified amount of time. Items put into a session will stay there, until the session ends.

ASP.NET还可以从缓存中删除项时可用内存量变得很小。

ASP.NET can also remove items from cache when the amount of available memory gets small.

另一个区别:会话状态可以保持外部的(状态服务器,SQL服务器)和你的Web应用程序(用于负载平衡)的多个实例之间共享。这是不与高速缓存的情况。

Another difference: the session state can be kept external (state server, SQL server) and shared between several instances of your web app (for load balancing). This is not the case with the cache.

除了这些差异(如其他人指出):会话是每用户/会话,同时缓存每个应用程序

Besides of these differences (as others have noted): session is per user/session while cache is per application.

这篇关于缓存的优势VS会议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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