2

I am using cache to store the data but in some operations such as addition/updation I want to reload the i am using following method but it does not works, is there any other solution

Response.Cache.SetSlidingExpiration(true);

also tried

cache["MoiveLIst"] = null;

but no result

Above code should make the if condition true but it does not, and if block does not executes because cache is not null, how i can make it null

if(Cache ["MovieList"]==null)                  
{
     Cache.Insert("MovieList", _client.GetAllMovies(), null, timespane, System.Web.Caching.Cache.NoSlidingExpiration);
}
List<Movie> oData = Cache["MovieList"] as List<Movie>;
Damith
  • 62,401
  • 13
  • 102
  • 153
Sameer
  • 362
  • 3
  • 18
  • related to [What's the best method for forcing cache expiration in ASP.NET?](http://stackoverflow.com/questions/533867/whats-the-best-method-for-forcing-cache-expiration-in-asp-net) – Damith Oct 26 '11 at 06:29

1 Answers1

0

you can use Cache.Remove Method before inserting

if(Cache["MoiveLIst"] != null)
  Cache.Remove("MoiveLIst");

Cache.Insert("MovieList", _client.GetAllMovies(), null, timespane, System.Web.Caching.Cache.NoSlidingExpiration);
List<Movie> oData = Cache["MovieList"] as List<Movie>;
Damith
  • 62,401
  • 13
  • 102
  • 153