Posted on: 5/14/2011 4:04:54 AM | Views : 258

Hi Guys,
I wrote a simple program in C# in asp.net to load the label with the contents in the Cache which I inserted a value during "Page_Load" event. I set the sliding expiration to 5 seconds, but when I clicked the button after 5 seconds, it still displays the data saved in the cache.
Pls see the code below :
 
protected void Page_Load(object sender, EventArgs e) { Cache.Insert("KKK", "Its a Value", null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0,0,5,0), System.Web.Caching.CacheItemPriority.Default, null); } protected void btn_Click(object sender, EventArgs e) { if (Cache["KKK"] != null) lbl.Text = (string)Cache["KKK"]; else lbl.Text = "Cache Cleared!"; }  
Pls reply.
Thanks in advance.

Isaac

Go to the complete details ...