Вопрос

i have this insanely large database i want to print out data from, however since the database is pretty large, it normally takes about 10-20 minutes to execute from.

i really don't want the web people to wait that long for a page to show up, and was wondering if there was a way to pre-cache the sql data globally every 1 hour, for all to see?

i tryed to search google for aspx and background workers, and most anwsers i find, is that asp is not desgined for that, and i need to use a Windows service.. but as fare as i know, windows services does not support Web Browser access? or is there a way to run a WebServer with ASPX from a Windows Service?

i never ever worked with aspx before, and got no idea what i am doing, however i have about 2000 hours in vb.net

Это было полезно?

Решение

Check out this MSDN article: How to: Add Items to the Cache.

You probably want to add that data to the application cache, with a sliding expiration of 1 hour:

Cache.Insert("yourBigData", bigDataObject, _
    Nothing, System.Web.Caching.Cache.NoAbsoluteExpiration, _
    New TimeSpan(0, 60, 0))

Then, in your code, whenever you want to access that big data, check the cache first:

If(Cache("yourBigData") IsNot Nothing) Then
    ' Get your data out of the cache, and use that
    Dim yourBigData As DataTable = CType(Cache("yourBigData"), DataTable)
Else
    ' retrieve the data and add it to the cache again
End If

For a broader perspective, see this MSDN article on "Caching Application Data", especially this:

ASP.NET has a powerful, easy-to-use caching mechanism that allows you to store objects in memory that require extensive server resources to create

That seems like precisely your scenario.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top