应用程序 vs 会话 vs 缓存 [英] Application vs Session vs Cache

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

问题描述

以上所有内容的合适用例是什么?看来会话和缓存很相似,我想不出对应用程序有多大用处.

What is an appropriate use case for all of the above? It seems session and cache are quite similar, and I can't think of much use for application.

推荐答案

Application 和 Session State 有一个非常重要的区别:

Application and Session State have a very important difference:

应用程序状态是一个可供 ASP.NET 应用程序中的所有类使用的数据存储库.应用程序状态存储在服务器的内存中,比在数据库中存储和检索信息要快.与特定于单个用户会话的会话状态不同,应用程序状态适用于所有用户和会话.因此,应用程序状态是存储少量常用数据的有用位置,这些数据不会从一个用户更改为另一个用户

Application state is a data repository available to all classes in an ASP.NET application. Application state is stored in memory on the server and is faster than storing and retrieving information in a database. Unlike session state, which is specific to a single user session, application state applies to all users and sessions. Therefore, application state is a useful place to store small amounts of often-used data that does not change from one user to another

应用程序状态概览
会话状态概述

另一方面,缓存允许您将对象存储在内存中,这些对象需要大量服务器资源才能创建 - 它提供了强大的功能,允许您自定义项目的缓存方式和时间缓存 - 您可以设置广泛的属性,例如优先级和过期时间.

Caching, on the other hand, allows you to store objects in memory that require extensive server resources to create - it offers powerful features that allow you to customize how items are cached and how long they are cached - you can set extensive properties like priority and expiration.

缓存应用程序数据概述

尽管它们可能看起来很相似,但从最广泛的意义上来说,它们是截然不同的,并且在 ASP.NET 应用程序中扮演着不同的角色.

Although they might appear similar, they are distinctly separate and have different roles to play in an ASP.NET application in its broadest sense.

这篇关于应用程序 vs 会话 vs 缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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