ryanw-mobile / OctoMeter

🔥Kotlin Multiplatform Desktop/Android/iOS Energy Tracker app
Other
88 stars 8 forks source link

Cache User Profile #174

Closed ryanw-mobile closed 3 weeks ago

ryanw-mobile commented 1 month ago

Since the primary user of this app is ME, and I don't change my account info every single day, it would reduce a lot of processing if the userprofile is cache for the lifetime of the app.

Later we can add a button to invalidate the cache, but it is unusual we change the MPAN, meter serial, or tariff.

ryanw-mobile commented 3 weeks ago

To be more specific, we cache the getAccount() call, so that for the given accountNumber, we keep the object in memory within the same day.

Caching in the repository is a good idea because use cases can always call to get it without having to keep and pass around their own copy - so we preserve the single source of truth at the repository - while repository decide the retention of the data and the caller won't have to worry about it.