Caching data

Discussion in 'ASP .Net' started by 3P, Sep 22, 2009.

  1. 3P

    3P Guest

    I want to cache readonly data at application start and have it in cache
    till application stops/restarts.
    I can use static fields, Cache object or Application object.
    Which is best? I've read that Application is for compatibility with ASP
    and shouldn't be used for caching.
    3P, Sep 22, 2009
    #1
    1. Advertising

  2. 3P

    Patrice Guest

    As said Mark it won't make a huge difference. Else what matters is not what
    is the best practice but *why* it is the best practice.

    One advantage of the cache object i can think of, is that it allows also to
    handle the lifetime (see
    http://msdn.microsoft.com/en-us/library/system.web.caching.cache.aspx). In
    your case it doesn't seem to matter so keep whatever is in use and works...
    Hence perhaps this advice you saw...

    In all cases it's likely better to hide this from your main app so that you
    can change the implementation at will...

    --
    Patrice

    "3P" <> a écrit dans le message de groupe de discussion :
    op.u0oh67ojmsp0fz@mcs...
    > I want to cache readonly data at application start and have it in cache
    > till application stops/restarts.
    > I can use static fields, Cache object or Application object.
    > Which is best? I've read that Application is for compatibility with ASP
    > and shouldn't be used for caching.
    Patrice, Sep 23, 2009
    #2
    1. Advertising

  3. 3P

    3P Guest

    Dnia 23-09-2009 o 12:42:13 Mark Rae [MVP] <>
    napisa³(a):

    > "3P" <> wrote in message news:eek:p.u0oh67ojmsp0fz@mcs...
    >
    >> I want to cache readonly data at application start and have it in cache
    >> till application stops/restarts.
    >> I can use static fields, Cache object or Application object.
    >> Which is best?

    >
    > Practically, there is very little difference...
    >
    >
    >> I've read that Application is for compatibility with ASP and shouldn't
    >> be used for caching.

    >
    > Where have you read that...?
    >

    http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312607

    ASP.NET includes application state primarily for compatibility with
    classic ASP so that it is easier to migrate existing applications to
    ASP.NET. It is recommended that you store data in static members of the
    application class instead of in the Application object. This increases
    performance because you can access a static variable faster than you can
    access an item in the Application dictionary.
    3P, Sep 23, 2009
    #3
  4. 3P

    3P Guest

    >> http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312607
    >
    > Last Review: January 21, 2004
    > APPLIES TO
    > Microsoft ASP.NET 1.1
    > Microsoft ASP.NET 1.0
    >

    OK. But if it was for compatibility with ASP in ASP.NET 1.0 it's now for
    compatibility with ASP.NET 1.0 in ASP.NET 2.0.

    And this will be true always

    "...you can access a static variable faster than you can access an item in
    the Application dictionary."
    3P, Sep 23, 2009
    #4
  5. 3P

    3P Guest

    Dnia 24-09-2009 o 01:47:17 Mark Rae [MVP] <>
    napisa³(a):

    > "3P" <> wrote in message news:eek:p.u0qeizq2msp0fz@mcs...
    >
    >>>> http://support.microsoft.com/default.aspx?scid=kb;en-us;Q312607
    >>>
    >>> Last Review: January 21, 2004
    >>> APPLIES TO
    >>> Microsoft ASP.NET 1.1
    >>> Microsoft ASP.NET 1.0
    >>>

    >> OK. But if it was for compatibility with ASP in ASP.NET 1.0 it's now
    >> for compatibility with ASP.NET 1.0 in ASP.NET 2.0.

    >
    > Not true.
    >
    >
    >> And this will be true always

    >
    > Again, not true.
    >
    >
    >> "...you can access a static variable faster than you can access an item
    >> in the Application dictionary."

    >
    > Once again, not true.
    >

    And what about boxing/unboxing?
    3P, Sep 24, 2009
    #5
  6. 3P

    3P Guest

    Dnia 24-09-2009 o 18:14:22 Mark Rae [MVP] <>
    napisa³(a):

    > Negligible


    But it is slower and that's the point. You said it isn't.
    3P, Sep 24, 2009
    #6
  7. 3P

    3P Guest

    Dnia 24-09-2009 o 18:50:51 Mark Rae [MVP] <>
    napisa³(a):

    > "3P" <> wrote in message news:eek:p.u0rsvdkgmsp0fz@mcs...
    >
    >>> Negligible

    >>
    >> But it is slower and that's the point. You said it isn't.

    >
    > I have never, not even once, used the word "slower" anywhere in this
    > thread...
    >
    > For the record, I said:
    >
    > "Practically, there is very little difference..."
    > "There really is *no* appreciable difference"
    > "Negligible"
    >

    That's what I'm saying

    I cited
    > "...you can access a static variable faster than you can access an item
    > in the Application dictionary."


    And You said
    > Once again, not true.


    It is slower but it's neglibible. But IT IS slower.
    3P, Sep 24, 2009
    #7
    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:
    406
  2. Alex

    Page and Data Caching in .Net

    Alex, Oct 5, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    372
    Steve Drake
    Oct 16, 2003
  3. Troy Simpson

    Fragment Caching inside page caching?

    Troy Simpson, Jan 19, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    785
    Troy Simpson
    Jan 19, 2004
  4. JimLad
    Replies:
    3
    Views:
    912
    JimLad
    Jan 21, 2010
  5. nullref

    data grid - data caching help

    nullref, Dec 7, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    122
    nullref
    Dec 7, 2005
Loading...

Share This Page