Background:
I have a website/service that I'm building where the bulk of my data comes from an external API. This API has a limit of 150 000 requests per day. The data is basically live data and I want to throttle the amount of times I hit their endpoints (basically cache it).
So my plan is to run queries against this API almost like on a schedule and store the responses in my database. If an entry in my table is older than 10 minutes I want to make a request to the API and get fresh data.
By querying the data every 10 minutes, in a worst case scenario, I can get down to ~50 000 requests per day.
I'm not sure what the right approach is. I'm mainly a frontend/React developer so my experience designing backends with caching and scale in mind is limited.
Has anyone done something similar, if so, how did you approach this? I'd like to get some kind of high level overview of how to design such a system.
I can probably set up a Resource class that gets the data but as I've looked in the documentation, the Resource is usually consumed directly by the views. Can I use my Resource to update the underlying DB with the data?
I've also thought about using something like Redis instead of the DB (but then I can't really decorate the data and set up relationships which has been really nice).
I hope my question is clear enough :)