Cache Object Question - Simple

Last post 08-20-2009 7:50 AM by prabhat chandra prabhakar. 4 replies.

Sort Posts:

  • Cache Object Question - Simple

    08-18-2009, 4:53 PM
    • Member
      142 point Member
    • kjmcad
    • Member since 07-28-2003, 11:17 AM
    • Richmond, VA
    • Posts 90

    If I have two user controls on a page and they both save a value to

    HttpRuntime.Cache["MyDate"]

    Will they be overwriting each others values?

     

    This question always confuses me. 

    The Analytical Web Architect
    http://analyticalarchitect.blogspot.com/
  • Re: Cache Object Question - Simple

    08-18-2009, 7:25 PM
    Answer
    • All-Star
      98,112 point All-Star
    • mbanavige
    • Member since 11-06-2003, 1:29 PM
    • New England, USA
    • Posts 10,347
    • Moderator
      TrustedFriends-MVPs

    kjmcad:

    If I have two user controls on a page and they both save a value to

    HttpRuntime.Cache["MyDate"]

    Will they be overwriting each others values?

     

    This question always confuses me. 

     

    Yes.  There is a single Cache - so those controls would overwrite each others values

    Mike Banavige
    ~~~~~~~~~~~~
    Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/
  • Re: Cache Object Question - Simple

    08-18-2009, 9:27 PM
    • Star
      12,577 point Star
    • malcolms
    • Member since 06-12-2008, 4:38 AM
    • Melbourne, Australia
    • Posts 2,062

    Just remember the ASP.NET session is unique per user, whereas the ASP.NET cache is available to all users.

    Sincerely,
    Malcolm Sheridan

    Microsoft Certified Solution Developer
    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as
    Answer" if a marked post does not actually answer your question.
  • Re: Cache Object Question - Simple

    08-20-2009, 3:51 AM
    Answer

     Hi kjmcad,

    Caching means temporary storage of data in memory that is highly-demanding and frequently used in order to accelerate performance and for quick access to various essential information.

    And, the Cache object is based on the all users in the application.

    So from your question, the answer is that the last Cache item will overwrite the last one by the same item name.

    If you want to share the data by the single user, you can use the Session object.

    By the way, I recommend you study all states in the ASP.NET.

    Nine Options for Managing Persistent User State in Your ASP.NET Application
    http://msdn.microsoft.com/en-us/magazine/cc300437.aspx

    All States in ASP.NET
    http://forums.asp.net/p/1392899/2986337.aspx#2986337

    Let me know whether that answers your question, or if I've missed something.

    Best Regards,
    Bober Song
    --------------------------------
    Please remember to click “Mark as Answer” on the post that helps you
  • Re: Cache Object Question - Simple

    08-20-2009, 7:50 AM

    if you want to store anything in cache object  then you can store in no of pages

    its like a session object only difference is that  session variable store per user basis

    but cache variable object store every user value.

    Thanks

Page 1 of 1 (5 items)