Reputation: 31
What's the difference between:
HttpRuntime.Cache["key"]
HttpContext.Current.Cache["key"]
HttpContext.Current.Application["key"]
are there any major differences between these memories?
Upvotes: 3
Views: 105
Reputation: 3572
HttpContext.Current.Cache
and HttpRuntime.Cache
are the same, the context cache prop just returns the runtime Cache. HttpRuntime
and HttpContext
just return handles to this object.
HttpRuntime.Cache
is recommended but likely won't make a difference in most applications.
HttpContext.Current.Application
is not a cache, its a global named value collection. if you add an object to Application it will stay until a an appdomain recycle. If you put an object in cache, it not guaranteed to be there when you fetch it. The cache is free to throw it away if the cache get too large, or the object has fetched often enough.
Upvotes: 1