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).
With this flexibility there is an extremely important piece missing from HttpRuntime.Cache - and that is thread safety. Not from inside of the Cache, but from the external code that accesses it. Websites under high load could cause a cache item to be populated multiple times. Too much thread eats too much cpu!!!
If your cache item was requested one time from the cache (as in to populate it) then when the expiration time comes, the cache item expires based upon the rules that the developer set. If there is subsequent access from the cache item, that information is recorded.
There are two main differences between these caching frameworks. Firstly, the Caching Application Block in EntLib allows you to define both an absolute expiration and a sliding expiration for an expiration policy while HttpRuntime. Cache only supports one or the other. Secondly, EntLib requires a decent amount of configuration whereas HttpRuntime.
If this value is the equivalent of 20 minutes, the object will expire and be removed from the cache 20 minutes after it was last accessed. If you are using sliding expiration, the absoluteExpirationparameter must be NoAbsoluteExpiration. priority CacheItemPriority
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)
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