cache question

  • Thread starter Thread starter Mike P
  • Start date Start date
M

Mike P

What is the difference between putting an object into the cache this way
:

Cache["ObjName"]

and this way :

HttpContext.Current.Cache.Add

For example, does using Cache["ObjName"] add to the collection created
by the second command or not?
 
Hi,

Mike P said:
What is the difference between putting an object into the cache this way
:

Cache["ObjName"]

and this way :

HttpContext.Current.Cache.Add

I think it's the same. Page.Cache is just a wrapper around
HttpContext.Current.Cache.

In the same way Add/Get are methods that are called as needed from the Item
property.
 
That's about right as Ignacio points out. The reason for these differences
is that the Httpcontext call allows the caller to access the context object
outside of a calling page, like in a webservice for instance.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET - MS Press
Professional VSTO 2005 - Wrox/Wiley
OWC Black Book www.lulu.com/owc

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

Mike P said:
What is the difference between putting an object into the cache this way
:

Cache["ObjName"]

and this way :

HttpContext.Current.Cache.Add

I think it's the same. Page.Cache is just a wrapper around
HttpContext.Current.Cache.

In the same way Add/Get are methods that are called as needed from the
Item property.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top