Application Data Cache - Quartz.NET vs Task list?
I am working on designing an application data cache for a large system in .NET.
The application data cache will be polling from multiple (10+) different systems or databases. It will also required to be refreshed at the certain intervals (30 minutes).
There are two options coming up to me.
The first one is to use Quartz.NET (or other scheduler framework) to trigger the cache builder at certain interval. It seems that I can easily control the intervals in configuration file and the scheduling is very flexible.
The second option is to use Task list, where one or many tasks will be pulling data and building the cache and the last one will be sleeping for a configurable time period. Then I can trigger the task list and let it run until the application close.
Right now, I am more inclined to the second option where I can pass in cancellation token so there will be more control over the start up and shut down process. Also, individual task can be break down to define dependen开发者_开发技巧cies like task hierarchy.
Which way above is better? Is there any better way?
Of the two options you are considering I would recommend a scheduler, because:
- It's something you don't have to write and maintain yourself.
- Schedulers can persist the schedules, so if the app restarts or you reboot, the scheduler handles it.
- The tasks are called jobs in the schedulers (in Quartz.net anyway) and you can set them to run at separate intervals. You can also have one job trigger other jobs.
- Schedulers offer programmatic access to schedules and jobs, so you can pause, add or remove jobs as needed.
Well if it is standard Asp.Net and SQL server, explore SQLCacheDependency. Its event based and will be triggered whenever there is a change in the undelying database tables. You dont have to poll the DB everytime.
精彩评论