Asp.net(C#)-显示所有缓存 清除所有缓存
生活随笔
收集整理的這篇文章主要介紹了
Asp.net(C#)-显示所有缓存 清除所有缓存
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?//清除所有緩存
????protected?void?RemoveAllCache()?
????{?
???????System.Web.Caching.Cache?_cache?=?HttpRuntime.Cache;?
???????IDictionaryEnumerator?CacheEnum?=?_cache.GetEnumerator();?
???????ArrayList?al?=?new?ArrayList();?
???????while?(CacheEnum.MoveNext())?
???????{?
??????????al.Add(CacheEnum.Key);?
???????}?
???????foreach?(string?key?in?al)?
???????{?
??????????_cache.Remove(key);?
???????}?
???????show();?
????}?
????//顯示所有緩存?
????void?show()?
????{?
???????string?str?=?"";?
???????IDictionaryEnumerator?CacheEnum?=?HttpRuntime.Cache.GetEnumerator();?
???????
???????while?(CacheEnum.MoveNext())?
???????{?
??????????str?+=?"緩存名<b>["?+?CacheEnum.Key+"]</b><br?/>"?;?
???????}?
???????this.Label1.Text?=?"當前網站總緩存數:"?+?HttpRuntime.Cache.Count?+?"<br?/>"+str;?
????}
????protected?void?RemoveAllCache()?
????{?
???????System.Web.Caching.Cache?_cache?=?HttpRuntime.Cache;?
???????IDictionaryEnumerator?CacheEnum?=?_cache.GetEnumerator();?
???????ArrayList?al?=?new?ArrayList();?
???????while?(CacheEnum.MoveNext())?
???????{?
??????????al.Add(CacheEnum.Key);?
???????}?
???????foreach?(string?key?in?al)?
???????{?
??????????_cache.Remove(key);?
???????}?
???????show();?
????}?
????//顯示所有緩存?
????void?show()?
????{?
???????string?str?=?"";?
???????IDictionaryEnumerator?CacheEnum?=?HttpRuntime.Cache.GetEnumerator();?
???????
???????while?(CacheEnum.MoveNext())?
???????{?
??????????str?+=?"緩存名<b>["?+?CacheEnum.Key+"]</b><br?/>"?;?
???????}?
???????this.Label1.Text?=?"當前網站總緩存數:"?+?HttpRuntime.Cache.Count?+?"<br?/>"+str;?
????}
轉載于:https://www.cnblogs.com/wangyong969/archive/2008/12/17/1356928.html
總結
以上是生活随笔為你收集整理的Asp.net(C#)-显示所有缓存 清除所有缓存的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 人工智能的未来是否真的会成为工人的乌托邦
- 下一篇: LitePal遇到的坑