I am trying to remove the cache using the HttpRuntime.Cache.Remove(key) but invain. I wonder what are the best practices for using HttpRuntime.Cache.
Regards
The Remove method works perfectly fine and removes the item from the cache given its key. Here's an example:
class Program
{
static void Main()
{
// add an item to the cache
HttpRuntime.Cache["foo"] = "bar";
Console.WriteLine(HttpRuntime.Cache["foo"]); // prints bar
// remove the item from the cache
HttpRuntime.Cache.Remove("foo");
Console.WriteLine(HttpRuntime.Cache["foo"]); // prints empty string
}
}
It's probably the way you are using it that is wrong. Unfortunately this hasn't been specified in your question so that's as far as we can help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With