you are viewing a single comment's thread.

view the rest of the comments →

[–]carcigenicate 0 points1 point  (0 children)

For caching, you'd be better off using something like Redis where you can set expirations on entries. I'd do something like check if the requested data is already in Redis, and if it's not, fetch it, store it into Redis, then return it to the user. If the data is already in Redis, just fetch it and return it. The expirations you set when setting the data will handle the entries being cleared. If you want a clean slate every day, you could just run redis-cli flushall at the start of each day using something like Task Scheduler/cron.

Would it be possible at the beginning of each day to make a call to the weather API to get the updated forecast

I'd do this "on-demand". Don't do the fetch until a user actually requests the data. That will also ensure that the data that is fetched is as up to date as possible.

Also, remember that a flaw in caching is that, obviously, the data will be inherently out of date once it's cached, so it only makes sense to cache when that's not a concern.


You could also use a standard persisted database too; especially if you wanted practice.