How to maintain huge number of key value pairs globally.

Last post 07-03-2009 10:24 AM by integrasol. 4 replies.

Sort Posts:

  • How to maintain huge number of key value pairs globally.

    07-03-2009, 7:48 AM

    hi all, I have to query a Telecom based server based on user request on a web page. there are about 50K objects / key value pairs, that needs to be fetch from the telecom server per request. Now, I don't want to fetch this huge volume of data each time from the telecom server. Insted I want to maintain these key value pairs globally available for all the web users to query. Please advice how to maintain this data in the ASP.NET application thread safe.

    Please: Don't forget to click "Mark as Answer" on the post that helped you.
    ----------------------------------
    Siva Prakasam
    Senior Software Engineer,
    TouchPoint Solutions,
    Chennai.

    inboxofsiva@gmail.com
  • Re: How to maintain huge number of key value pairs globally.

    07-03-2009, 7:55 AM
    Answer
    • Star
      8,730 point Star
    • integrasol
    • Member since 06-05-2009, 11:18 AM
    • Denmark & Spain
    • Posts 1,628

     You say globally, so I assume this is for the entire Web application, right? If so, check out Application state, using the Application property of the page. If we're talking about 50k in total that should not be a problem. http://msdn.microsoft.com/en-us/library/ms178594.aspx

     

    On second thought, you might want to look at caching as well, as I think you're saying that there is way more than 50K, right? http://msdn.microsoft.com/en-us/library/xsbfdd8c.aspx

    Thanks

    Carsten

    Please click Mark as Answer if this post is of help to you. :-)



    My Blog
  • Re: How to maintain huge number of key value pairs globally.

    07-03-2009, 8:06 AM
    • Star
      12,601 point Star
    • malcolms
    • Member since 06-12-2008, 4:38 AM
    • Melbourne, Australia
    • Posts 2,069

    If these values are for all users, then store these values in the ASP.NET Cache.  That way they're accessible to all users.  So you could write a property like this:

    public Dictionary<int, string> YourValue
    {
         get {
               Dictionary<int,string> values = Cache["yourValue"] as Dictionary<int,string>;
               if(values == null)
               {
                      // retrieve values
                      Cache["yourValue"] = values;
                }
                return values;
         }
    }


    If they're coming from a SQL Server database then you can use SQL Cache deoendency.  Then SQL will notify you when the data becomes invalid then you can refresh the cache.  I wrote an article on it here:

    http://www.dotnetcurry.com/ShowArticle.aspx?ID=263


    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: How to maintain huge number of key value pairs globally.

    07-03-2009, 9:05 AM

    Thanks Integroasol,


    I would consider the Application level storing, but I'm not sure how fast the application object is liable to parse/iterate to get any particular key value is requested.Also, how far I can prevent the application object getting flushed.

    I think, Cache will be in consistent as the data grows it flushes the data without any intemation!


    Regards

    Siva




    Please: Don't forget to click "Mark as Answer" on the post that helped you.
    ----------------------------------
    Siva Prakasam
    Senior Software Engineer,
    TouchPoint Solutions,
    Chennai.

    inboxofsiva@gmail.com
  • Re: How to maintain huge number of key value pairs globally.

    07-03-2009, 10:24 AM
    • Star
      8,730 point Star
    • integrasol
    • Member since 06-05-2009, 11:18 AM
    • Denmark & Spain
    • Posts 1,628

    AFAIK, the Application object uses a Hashtable for storing the key-value pairs, and it is generally very fast for accessing. Application variables are kept in memory, but when the the application is recycled so are the application variabales. You could check when accessing, re-read the objects and restore in Application, if the application has been recycled. Alternatively, read the objects in the Application_Start event handler in Global.asax.

    Otherwise, the Cache is your best bet, especially if you're reading from SQL Server as the other poster, points out.

    Thanks

    Carsten

    Please click Mark as Answer if this post is of help to you. :-)



    My Blog
Page 1 of 1 (5 items)