Advantages of Cache vs Session

2019-01-03 09:22发布

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

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.

8条回答
放荡不羁爱自由
2楼-- · 2019-01-03 10:07

See this answer.

Session can kill your app performance, unless you use some backend provider like memcached or velocity. Generally you should avoid it.

查看更多
Animai°情兽
3楼-- · 2019-01-03 10:08

Cache is in the Application scope with the purpose of reducing the number of times a piece of data is obtained. Session is in a user's session scope with the purpose of giving a particular user state.

查看更多
登录 后发表回答