在global.asax Application_Start中缓存大量数据,windows azure角色
我目前正在 Application_Start 中做大量工作,需要一两个小时才能将 2 GB 数据缓存到内存中,以使我的应用程序高效运行。
使用此方法,在这些进程完成之前,Azure Web 角色实例不可用。我正在插入 HTTPRuntime 缓存,因此我无法使用 WebRole.cs OnStart() 或 Run() 方法(它们无权访问此缓存)。
您能想到其他方法来将这些数据加载到缓存中,同时也使网站在此缓存期间可用吗?该网站在数据加载时运行良好,只是速度不那么快。
非常感谢, -凯文
I am doing a ton of work currently in Application_Start, and it takes an hour or two to cache the 2 gigs of data into memory that make my application operate efficiently.
Using this method, the Azure web role instance(s) are not available until these processees are complete. I am inserting into the HTTPRuntime cache, so I cannot use the WebRole.cs OnStart() or Run() methods (they don't have acceess to this cache).
Can you think of alternate ways that I can get this data loaded into the cache, while also making the website available during this caching period? The website operates fine while the data is loading, just not as fast.
Thanks so much,
-Kevin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将您的方法称为缓存有点牵强,因为缓存通常是按需的(或惰性缓存),而不是在实际需要之前加载内容的预缓存。
It's a bit of a stretch to call your approach caching, because caching is usually on demand (or lazy caching), as opposed to pre-caching where content is loaded before it is actually required.
您可以使用单独的线程将数据添加到缓存中。即,创建一个单独的线程并开始使用该线程缓存数据。
同时您的应用程序应该可以完美运行。
You may add the data in the Cache using a separate thread. i.e., create a separate thread and start caching the data using that thread.
You application should serve perfectly in the meanwhile.