G
Guadala Harry
I want to create a STATIC method that removes all items from the Cache.
Questions:
1. Is a safe thing to do (any threading issues?)
2. Is the following code a good way to get the job done - given that there
is apparently no method like Cache.Clear() or Cache.Items.Clear()? Or am I
missing an easier way to do it?
string currentKey= "";
System.Collections.IDictionaryEnumerator cacheContents =
System.Web.HttpContext.Current.Cache.GetEnumerator();
while (cacheContents.MoveNext()) {
currentKey = cacheContents.Key.ToString();
System.Web.HttpContext.Current.Cache.Remove(currentKey);
}
Thanks!
-GH
Questions:
1. Is a safe thing to do (any threading issues?)
2. Is the following code a good way to get the job done - given that there
is apparently no method like Cache.Clear() or Cache.Items.Clear()? Or am I
missing an easier way to do it?
string currentKey= "";
System.Collections.IDictionaryEnumerator cacheContents =
System.Web.HttpContext.Current.Cache.GetEnumerator();
while (cacheContents.MoveNext()) {
currentKey = cacheContents.Key.ToString();
System.Web.HttpContext.Current.Cache.Remove(currentKey);
}
Thanks!
-GH