Application state vs. Cache API

Discussion in 'ASP .Net' started by Daniel Walzenbach, Jul 10, 2004.

  1. Hi,



    I need to cache infrequently changed data used by the entire application.
    Does anybody know whether using Application state
    (Application["YourGlobalState"] = somevalue;) or the Cache API
    (Cache.Insert) is more preferable?



    Thanks a lot



    Daniel
     
    Daniel Walzenbach, Jul 10, 2004
    #1
    1. Advertisements

  2. Daniel Walzenbach

    Scott Allen Guest

    The cache object is more flexible in the long run. You can set a
    duration and a priority for the cached item, for instance.
     
    Scott Allen, Jul 10, 2004
    #2
    1. Advertisements

  3. The cache is good, but it is considered volatile. There is never any
    guarantee that the data is there. The item may be removed when it expires or
    some condition is met (something you explicitly set), or the runtime may
    remove the item when memory gets low. In contrast, the application variables
    are there for the duration of the applications life, unless explicitly
    removed by you and it provides methods to synchronise access to the
    varibales as well. (.Lock for example).

    --
    - Paul Glavich
    Microsoft MVP - ASP.NET


     
    Paul Glavich [MVP - ASP.NET], Jul 10, 2004
    #3
  4. Hi Daniel,

    I think Scott's suggestion is reasonable since the ASP.NET's Cache Object
    not only provide the share space across the whole application scope but
    also provide many mechenism to control's lifecyle(the different kind of
    dependences). Here are some tech articles on ASP.NET caching:

    #ASP.NET Caching: Techniques and Best Practices
    http://msdn.microsoft.com/library/en-us/dnaspp/html/aspnet-cachingtechniques
    bestpract.asp?frame=true

    #Using the ASP.NET Application Cache to Make Your Applications Scream
    http://www.codeguru.com/columns/Experts/article.php/c4231/

    #Manage Detail Pages Across Multiple Platforms with Centralized Data Caching
    http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnaspp/ht
    ml/cencachv3.asp

    Hope also helpful.

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Get Preview at ASP.NET whidbey
    http://msdn.microsoft.com/asp.net/whidbey/default.aspx
     
    Steven Cheng[MSFT], Jul 10, 2004
    #4
  5. Thank you!

    Daniel

     
    Daniel Walzenbach, Jul 10, 2004
    #5
  6. True but as with all caching, one ALWAYS checks to see if the data is in the
    cache and if not gets fresh data. So unless connection is iffy, this really
    should be a concern.

    Harry

     
    Harry Simpson, Aug 26, 2004
    #6
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.