简体   繁体   中英

Application variable refresh in an mvc web app

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM