I have a database table that holds data related to my image gallery, and I want to store this information on my server.
Basically, each time a user goes into my gallery I want to read from my server instead of querying the database each time.
I found ApplicaionState that is ideal for my use, but I want to do is create a Global method that every 2 hours re-gets the data from the database so I can be sure I have the latest version.
How can I do this?
Thanks
You should better use ASP.Net caching. When you add something in cache, you can defines how long the object can remain in the cache.
When you load your page, check if the object is in cache. If true, use it, if false, rebuild it by reading the DB.
You can also cheat a bit to preload db data by catching the expiration of the cache item, to force reload of the data.