views:

78

answers:

1

I have an Application level variable that gets loaded from a database when the application starts. Now when accessing the variable, I check to see if it is not null. If it is not null I use it, if it is null I initialize it from the database, then use it.

My question is how can I make sure that this variable is refreshed atleast once a day? Is there something in .net or the MVC framework to help with this?

Does IIS unload an application if it has not accessed for a while? If so then my variable would be refreshed each time the app is reloaded.

Thanks

+2  A: 

You could use the class System.Web.Caching.Cache to store the variable with an expiration time. That way once a day is up the value will be cleared and your code could reload it from the DB.

Justin Ethier