Cache object in .NET technologies very power full feature and we all use it for increasing out application performance. In one of my project i need to remove all of the my cache once some task was completed. So i have done some digging and i have found some beautiful way of removing all the cache object. As you know cache it self is dictionary entry object so we can always remove them via loop here are some of code examples from which we can remove the all the cache object.
//Following namespace you need.
using System.Collections;
using System;
using System.Collections.Generic;
using System.Web;
IDictionaryEnumerator cacheEnumerator = HttpContext.Current.Cache.GetEnumerator();
while (cacheEnumerator.MoveNext())
{
HttpContext.Current.Cache.Remove(cacheEnumerator.Key.ToString());
}
foreach (DictionaryEntry dEntry in HttpContext.Current.Cache)
{
HttpContext.Current.Cache.Remove(dEntry.Key.ToString());
}
0 comments:
Post a Comment
Your feedback is very important to me. Please provide your feedback via putting comments.