Application State and Custom Collection Maintenance

Discussion in 'ASP .Net' started by Jeff S, Nov 4, 2003.

  1. Jeff S

    Jeff S Guest

    I'm storing a list of widgets in a database. The list changes infrequently
    (twice per week at most), and is relatively short (200 items at most, with
    very little detail per item). A small subset of all possible widgets will be
    displayed on a page (using VB.NET/code behind). I plan to populate a custom
    collection/class with a list of all possible widgets. The class will include
    a method that returns the required subset. Of course the logic will have to
    hit the database in order to populate a custom collection. Because I want to
    minimize the number of hits on the database, and because the class will hold
    relatively little data, and because and the data is identical for all users,
    I think it makes sense to maintain it in the Application state.

    My questions:
    1. When/where should I instantiate and initialize the custom
    collection/class? It seems that if I do it in the page_load event of
    Default.aspx, that I'd hit the database too much (every time a user opens
    the application). But, if not during that event, then when should it be
    initialized?

    2. When the list of widgets gets updated in the database (twice per week or
    so), the custom collection/class would need to be refreshed in order to
    include the changes made in the database. What would be a good stragegy for
    keeping the custom collection/class synchronized with the database?

    Thanks in advance.

    Jeff
    Jeff S, Nov 4, 2003
    #1
    1. Advertising

  2. Jeff S

    Natty Gur Guest

    Hi,

    1) You can initialize the cache in application_onstart event.
    (Initialization will happen just once).

    2) You can use two attitudes:
    - wrap accessing cache data with method that will check if cache
    expired and if expired re-add the data from DB to cache.
    - catch the callback event that send by cache after the cache releases
    the data and add again the data from the DB.

    HTH

    Natty Gur[MVP]
    Phone Numbers:
    Office: +972-(0)9-7740261
    Fax: +972-(0)9-7740261
    Mobile: +972-(0)58-888377


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur, Nov 4, 2003
    #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. =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=

    Help on maintenance state information ???

    =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?=, Sep 13, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    357
    =?Utf-8?B?Q3VydF9DIFtNVlBd?=
    Sep 13, 2005
  2. Øyvind Isaksen
    Replies:
    1
    Views:
    964
    Øyvind Isaksen
    May 18, 2007
  3. Scott McNair

    AJAX and State Maintenance

    Scott McNair, Dec 9, 2008, in forum: ASP .Net
    Replies:
    3
    Views:
    291
    Scott McNair
    Dec 9, 2008
  4. Jeremy S.

    Wizard Design and State Maintenance

    Jeremy S., Jul 27, 2009, in forum: ASP .Net
    Replies:
    12
    Views:
    696
    Gregory A. Beamer
    Jul 28, 2009
  5. ewolfman

    Multiview, server controls and state maintenance

    ewolfman, Oct 17, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    161
    ewolfman
    Oct 17, 2005
Loading...

Share This Page