Object Store for Sun Events (moments) to reduce processing load?

I've had a suggestion from a user to cache the next sun event and only do the calculation once a day, because it appears to be causing device slowdowns or laggy behaviour on the F3HR.

I've given it a shot but am struggling with how to store and retrieve the computed values. I understand that the Object Store don't work with moments etc.

So, I have a couple of questions.
  • Does the sun event calculation actually create a heavy load on the device?
  • What are the best practices for caching objects like moments?
Thanks,
Kev
  • Anytime you can reduce how much code you run on a regular basis the better. How much impact there is on the battery, really depends on the code.

    As far as caching the rise and set, you can do it without using a moment. You can use value() on it and get tie time in seconds since Jan 1,1970 and store it as a number, or even simpler store the date, rise and set

    so date could be mmdd, and rise and set, the number of minutes since midnight or something. (allows for 12/24 hr settings changes) or just hhmm.

    Caching this means you have to check when you start if it needs to be calculated for the current day, calculate it when the day changes, and consider the case where the location changes. (get on a plane, travel a few hours, and recalculated for the new lat/lon on the same day.) Without caching, travel just means firing up GPS to get the new location.