Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the expiration period of items in HttpRuntime Cache....?

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).

like image 499
Sunil Avatar asked May 10 '13 13:05

Sunil


People also ask

What is missing from httpruntime 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!!!

What happens when a cache item expires?

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.

What is the difference between entlib and httpruntime cache?

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.

How long does an object stay in the cache?

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


1 Answers

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)

like image 173
Kenneth Avatar answered Sep 24 '22 03:09

Kenneth