static initialization of a class used by asp.net-- how long will the initialized values last? -


we're writing class we'll use in our asp.net site. class pull down json using httpclients , such, , use provide information other clients.

some of information change infrequently , doesn't make sense query on each client request.

for reason i'm thinking of making static constructor in new class slow-changing information , stashing results in few static member variables. that'll save few httprequests down line-- think.

my question is, how long can expect information there before class recycled asp.net , new 1 comes play, static constructor called once more? i'm trying worth it? there better ways in asp.net go this?

i'm no expert on asp.net thread pooling or how works , objects recycled , when.

typical use of new class (mycomponent, let's call it) below, if helps any.

//from mywebpage.aspx.cs: var mycomponent = new mycomponent(); mycomponent.dostuff(); //etc etc.   //method calls above may rely on  //of data stored static constructor call. 

static fields last long appdomain. strategy have in mind consider asp runtime may recycle app pool or may restart web site/server.

as extension idea, save data locally (via separate service dedicated or hard drive) , refresh @ specific intervals required. still use static field in asp.net storing value, aquire above local service or disk ... here recommend system.lazy instantiation , publication options on thrread safe (see constructor documentation).


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -