cache question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike P

    #1

    cache question

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

    Cache["ObjName"]

    and this way :

    HttpContext.Cur rent.Cache.Add

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



    *** Sent via Developersdex http://www.developersdex.com ***
  • Ignacio Machin \( .NET/ C# MVP \)

    #2
    Re: cache question

    Hi,

    "Mike P" <mike.parr@gmai l.comwrote in message
    news:u1VIARW5HH A.1148@TK2MSFTN GP05.phx.gbl...
    What is the difference between putting an object into the cache this way
    :
    >
    Cache["ObjName"]
    >
    and this way :
    >
    HttpContext.Cur rent.Cache.Add
    I think it's the same. Page.Cache is just a wrapper around
    HttpContext.Cur rent.Cache.

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


    Comment

    • Alvin Bruney [MVP]

      #3
      Re: cache question

      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 )" <machin TA laceupsolutions .comwrote in
      message news:usThIKZ5HH A.5724@TK2MSFTN GP05.phx.gbl...
      Hi,
      >
      "Mike P" <mike.parr@gmai l.comwrote in message
      news:u1VIARW5HH A.1148@TK2MSFTN GP05.phx.gbl...
      >What is the difference between putting an object into the cache this way
      >:
      >>
      >Cache["ObjName"]
      >>
      >and this way :
      >>
      >HttpContext.Cu rrent.Cache.Add
      >
      I think it's the same. Page.Cache is just a wrapper around
      HttpContext.Cur rent.Cache.
      >
      In the same way Add/Get are methods that are called as needed from the
      Item property.
      >
      >

      Comment

      Working...