查看状态和缓存哪个最好? [英] view state and caching which is best?

查看:83
本文介绍了查看状态和缓存哪个最好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用视图状态完成了分页。但是我们还有其他选择,例如缓存,会话。那么性能最佳?

i have done paging using view state. but we have other choice such as caching,session .So which one best in performance?

推荐答案

这两种方法都不是分页的好方法,也不是你列出的选项使用viewstate。当您将结果放入会话或缓存中时,这些结果将存在于服务器的内存中,直到它们被删除。如果将数据存储在视图状态中,则它将存储在客户端上,并且仅在用户位于该页面上时才存在。如果他们导航到其他地方,数据就会消失。



在数据存储级别实现分页要好得多......所以如果你的数据是在SQL中,那么确保SQL只返回您需要的结果,例如,如果您在第2页上,则结果为11到20。使用SQL进行Google分页,可以使用各种技术进行分页。
Neither are good ways to do paging, but of the options you have listed use viewstate. When you put your results in the session or cache then those results exists in the server's memory until they are removed. If you store the data in the viewstate it is stored on the client and only exists while the user is on that page. If they navigate elsewhere the data is gone.

It is far better to implement paging at the data store level...so if your data is in SQL then make sure SQL only returns the results you need, so results 11 to 20 if you are on page 2, for example. Google paging with SQL for various techniques that let you do this.


这篇关于查看状态和缓存哪个最好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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