<<You aren't the only thing adding stuff to the cache>>
That's a big one... didn't know that. Thank you.
Too bad I can't have a dependency on database tables. I already put things
in the Cache with a sliding expiration - but anything still in the Cache
reflecting the current state of the underlying database must get removed
from the Cache whenever the database gets updated. Short of waiting until
ASP.NET/2, is there any elegant way to create a dependency between Cached
data and SQL Server db tables? The only time I explicitly blow things out of
the Cache is when the db gets updated.
-GH
"Joe Fallon" <jf******@nospamtwcny.rr.com> wrote in message
news:OC**************@TK2MSFTNGP14.phx.gbl...
I would not do that.
There are other things that use the cache too.
You aren't the only thing adding stuff to the cache.
You could seriously break stuff.
Use cache dependencies or expirations instead soyou can control the things
that you created and added to the cache.
--
Joe Fallon
"Guadala Harry" <GM**@NoSpam.com> wrote in message
news:OW**************@TK2MSFTNGP10.phx.gbl...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(curren tKey);
}
Thanks!
-GH