I'm building an
ASP.NET IMDb-like website which presents various information about movies to users, relying on 3rd party APIs to (initially) fetch movie info.
The IDs representing each movie on the website are identical to IMDb's (ID
tt1234567 points to the same movie on both websites).
The way movie info are fetched (and subsequently stored on SQL server) is as follows:
- User requests movie with id
- MVC checks if movie with id
tt1234567exists in the database.
- If not, it queries external APIs to fetch movie information and stores it in the database.
- If yes, it fetches the information directly from the database.
This works fine and I'm at the point where I'm implementing caching. There are some particular columns for each row in the
Movie table which change every certain amount of days (e.g. overall rating and number of votes for that movie in IMDb). As such, I need to implement a function where relevant columns of the row are updated after certain amount of time (e.g. every 10 days).
What would be the correct approach to do this? Should I implement a scheduled task which runs every 10 days and updates the needed columns in the DB, or should I somehow add caching into the mix?