none
Load data when webservices starts

    Question

  • I use asp.net and SQL Server database when performing task that looks like this: When starting web service I load data from SQL server and I need to use that data for my application vs. accessing it every time from a database.

    Also, this data needs to be refreshed hourly w/o affecting the website operation. I don’t know how to avoid this. Is there a workaround?

    Monday, July 01, 2013 9:47 AM

Answers

  • Hi,

    For refreshing the data:  ASP.Net Caching can be used, which has different options for expiration like time interval, File path and others. Here you can also have callBack events which will be triggered when the cache is expired. You can handle these events and load the data to your cache again.

    Please check the documentation for :

    System.Web.Caching.CacheDependency

    HttpContext.Current.Cache.Insert()



    Ricky

    Monday, July 01, 2013 10:37 AM

All replies

  • I suggest you use app start event for data loading.

    Also, you can use Application object for caching, in order to have your data available to all parts of application and add a property to memorize the last update time. After that, create another service to check the last update time every M minutes and update the data when the time comes.

    Monday, July 01, 2013 9:50 AM
  • Hi,

    For refreshing the data:  ASP.Net Caching can be used, which has different options for expiration like time interval, File path and others. Here you can also have callBack events which will be triggered when the cache is expired. You can handle these events and load the data to your cache again.

    Please check the documentation for :

    System.Web.Caching.CacheDependency

    HttpContext.Current.Cache.Insert()



    Ricky

    Monday, July 01, 2013 10:37 AM