c# - 强制所有 ASP.NET 缓存过期

标签 c# asp.net caching

是否有某种方法或其他方法强制 HttpContext 的缓存集合中的所有条目过期?

最佳答案

尝试这样的事情:

var enumerator = HttpRuntime.Cache.GetEnumerator();
Dictionary<string, object> cacheItems = new Dictionary<string, object>();

while (enumerator.MoveNext())
    cacheItems.Add(enumerator.Key.ToString(), enumerator.Value);

foreach (string key in cacheItems.Keys)
    HttpRuntime.Cache.Remove(key);

关于c# - 强制所有 ASP.NET 缓存过期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2884360/

相关文章:

c# - 授权策略的依赖注入(inject)

asp.net - 使用 VB.NET 在 ASP.NET 中的 detailsView 中集成 CKEditor

c# - 自定义 MVC5 ASP.NET Identity 中的 cookie 值

c# - ASP.NET。 Newtonsoft.Json.JsonSerializationException : 'Self referencing loop detected with type ' E_Store2021. Models.Product'

mongodb - 使用 mongodb 和 redis 的缓存失效策略

javascript - 如何为 RadioButtonList 的每个重复列设置不同的背景颜色

c# - 按联系人 ID 查询发票时 Xero api 不返回值

c# - DataView.Sort是性能瓶颈

internet-explorer - Internet Explorer 缓存位置

caching - 对可查询的数据集使用分布式缓存是否可行?