强制所有ASP.NET缓存过期

ryu*_*ice 9 c# asp.net caching

是否有方法或某些东西强制HttpContext的Cache集合中的所有条目到期?

Tej*_*ejs 18

尝试这样的事情:

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);
Run Code Online (Sandbox Code Playgroud)