5

What is the maximum expiration time we can set to an item in HttpRuntime Cache...?
Also what is the default expiration time..?

public static void Add(string pName, object pValue)
{
  System.Web.HttpRuntime.Cache.Add(pName, pValue, null, DateTime.Now.AddSeconds(60), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.High, null);
}

In above code 4th parameter is 'absoluteExpiration'.
What is the maximum value we can provide here...?

If I provide 10-05-2014, will that item available in cache for that long period...?
(This query is related to implementation of AppFabric cache. Trying to replace Httpruntime Cache with AppFabric Cache).

Sunil
  • 2,885
  • 5
  • 34
  • 41

2 Answers2

5

The maximum value of AbsoluteExpiration is basically NoAbsoluteExpiration. To set this you would pass it this field:

Cache.NoAbsoluteExpiration

Other than that you can use any value you want and it will cache it as long as you tell it to. However, this of course supposes that your server doesn't get reset, you don't clear the cache of AppFabric, etc. (if you'd use HttpRuntime.Cache it would also be necesarry that your application keeps alive)

Kenneth
  • 28,294
  • 6
  • 61
  • 84
0

It has been a default setting that the application pool of iis to recycle after the application some interval. This will stop your application and then the cache will be emptied, so setting longer time out than the application pool recycling timeout will have no effect. I think the point of caching is not to keep object alive forever, but increase performance by keeping them alive for a while.

mortb
  • 9,361
  • 3
  • 26
  • 44