MMM-OpenWeatherMapForecast icon indicating copy to clipboard operation
MMM-OpenWeatherMapForecast copied to clipboard

feat: add caching for OpenWeather API to reduce unnecessary calls; Refactor code structure for better readability

Open sisimomo opened this issue 1 year ago • 4 comments

  • 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.

sisimomo avatar Oct 06 '24 19:10 sisimomo

Thanks for your contribution. Could you please explain under what circumstances a caching is needed?

MarcLandis avatar Oct 11 '24 10:10 MarcLandis

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.

sisimomo avatar Nov 09 '24 21:11 sisimomo

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.

sisimomo avatar Jan 17 '25 05:01 sisimomo

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.

MaxDiOrio avatar Jan 18 '25 18:01 MaxDiOrio