Caching App Data

Discussion in 'ASP .Net Web Services' started by Dave T, Mar 12, 2008.

  1. Dave T

    Dave T Guest

    The data for my web app is an object model that consists of a class with a
    series of properties typed as generic.list(of SomeClass). The object model
    gets built up along the way by calls to SQL Server. Some of the data is
    global data, some of it is user data. Instead of making multiple calls to
    the DB to get the same data, I was thinking that I could cache the object
    model and retrieve it.

    To do that in .net 1.1, I would have done something like this

    Dim _GobalData as new GlobalDataObjectModel
    _GobalData = Cache("GlobalData")
    If _GlobalData Is Nothing Then
    _GlobalData = CreateGlobalData
    Cache("GlobalData") = _GlobalData
    End IF
    UseGlobalData()

    It seems caching in .net 2.0 is quite different. For one thing, there seems
    to be a problem with my reference to *cache*. Is it possible to do this? If
    so, what is the namespace for *cache*? Do I need to do this some other way?
     
    Dave T, Mar 12, 2008
    #1
    1. Advertising

  2. The namespace is System.Web.Cache. If you are having trouble, try
    HttpContext.Current.Cache.
    -- Peter
    Site: http://www.eggheadcafe.com
    UnBlog: http://petesbloggerama.blogspot.com
    Short Urls & more: http://ittyurl.net


    "Dave T" wrote:

    > The data for my web app is an object model that consists of a class with a
    > series of properties typed as generic.list(of SomeClass). The object model
    > gets built up along the way by calls to SQL Server. Some of the data is
    > global data, some of it is user data. Instead of making multiple calls to
    > the DB to get the same data, I was thinking that I could cache the object
    > model and retrieve it.
    >
    > To do that in .net 1.1, I would have done something like this
    >
    > Dim _GobalData as new GlobalDataObjectModel
    > _GobalData = Cache("GlobalData")
    > If _GlobalData Is Nothing Then
    > _GlobalData = CreateGlobalData
    > Cache("GlobalData") = _GlobalData
    > End IF
    > UseGlobalData()
    >
    > It seems caching in .net 2.0 is quite different. For one thing, there seems
    > to be a problem with my reference to *cache*. Is it possible to do this? If
    > so, what is the namespace for *cache*? Do I need to do this some other way?
     
    Peter Bromberg [C# MVP], Mar 12, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hypo
    Replies:
    6
    Views:
    430
  2. Troy Simpson

    Fragment Caching inside page caching?

    Troy Simpson, Jan 19, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    810
    Troy Simpson
    Jan 19, 2004
  3. Mark

    Caching data in a web app

    Mark, Aug 30, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    358
    Hermit Dave
    Aug 30, 2004
  4. Dave T

    Caching App Data

    Dave T, Mar 12, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    313
    Peter Bromberg [C# MVP]
    Mar 12, 2008
  5. JimLad
    Replies:
    3
    Views:
    929
    JimLad
    Jan 21, 2010
Loading...

Share This Page