获取站点所有缓存,以及清除站点缓存

在程序在开发阶段,有时候需要手动清理所有缓存进行测试,那么如何获取到系统所有缓存进行清除呢,

测试代码:

            System.Collections.IDictionaryEnumerator de = Cache.GetEnumerator();   //获取到所有系统缓存
            System.Collections.ArrayList list = new System.Collections.ArrayList();
            StringBuilder str = new StringBuilder();

            while (de.MoveNext())
            {
                list.Add(de.Key.ToString());
            }
            foreach (string key in list)
            {
                Cache.Remove(key);
                str.Append("<li>" + key + "......OK! <br>");
            }

 

posted @ 2016-09-01 10:53  赛跑的蜗牛  阅读(783)  评论(3编辑  收藏  举报