c# - 当您读取/写入缓存时,该信息处于什么级别?

标签 c# asp.net code-behind

假设在 C#/ASP.net 环境中有以下代码块:

// Read from the cache
object value = Cache["key"];
// Add a new item to the cache
Cache["key"] = value;
Cache.Insert(key, value);
Cache.Insert(key, value, CacheDependency);
Cache.Insert(key, value, CacheDependency, DateTime, TimeSpan);

现在,假设一个 IE9 浏览器打开了 3 个不同的选项卡。

该缓存项是否可用于每个选项卡?任何 future 打开的标签?或者它是否仅适用于具有创建它的网页的选项卡?

最佳答案

首先,Cache 是服务器端,其次,它在该 Web 服务器的所有用户之间共享,因此,与您拥有的用户一样多,他们将共享相同的 Cache 不考虑浏览器的对象。

参见:ASP.NET Caching Overview

关于c# - 当您读取/写入缓存时,该信息处于什么级别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30266322/

相关文章:

c# - ASP.NET 自定义控件 - 复合

javascript - visual studio 提示变量未声明

wpf - 使用 min(width, height)/2 作为半径在 WPF 中画一个圆

c# - 锁定对象以防止任何数据更改

c# - 可以将插件 DLL 存储在/Plugin 文件夹而不是/Bin 中吗?

c# - Azure DevOps Pipeline - dotnet restore 包内容哈希验证失败

c# - 隐藏网格中的列

c# - 为什么此代码会导致 "The name does not exist in the current context"错误?

c# - 谁能推荐一种使用 C# 执行以下字符串操作的方法

c# - 如何在 C# 中将 unicode 字符转换为其等效的转义 ascii