feat: add caching for OpenWeather API to reduce unnecessary calls; Refactor code structure for better readability
- Greatly improved code structure by refactoring logic into multiple functions for better readability.
- Implement cache mechanism for the OpenWeather API responses, reducing unnecessary API calls.
Thanks for your contribution. Could you please explain under what circumstances a caching is needed?
Hi, yes, definitely. It's mostly useful when you have multiple MagicMirror clients (monitors) powered by the same MagicMirror backend (server). That way, you can ensure that your OpenWeather API usage doesn’t scale up when serving more clients.
I have been using it for the past two months on 2 Mirror, and it seems to work very reliably.
@MarcLandis, could you consider merging it if you think it’s good? Alternatively, please let me know what I could improve to meet your expectations.
Would this also be beneficial if you have multiple modules on the same screen? I was just setting this up and was going to submit a request to cache the data so a screen with two modules doesn't make multiple API calls.