Now that we have Room DB properly set up,
we can modify the repository, given that all existing API interfaces are unchanged,
we can introduce a classic caching mechanism so that when it receives an API request:
It checks the local DB if the required data set exists
If we have enough local data, we return that locally
Otherwise, we run API calls and cache them before returning them to the caller
Characteristics:
We in some ways, also introduce offline mode - because it won't trigger HTTP error as we don't fire HTTP requests
We need to carefully examine when we should declare a "cache miss", because Octopus only publishes the rates for the next day, usually after 4PM, so requests before that time will not help getting anything more than we have locally.
This can help speed up the usage screen because we don't have to reload the rates for bill calculation
Now that we have Room DB properly set up, we can modify the repository, given that all existing API interfaces are unchanged, we can introduce a classic caching mechanism so that when it receives an API request:
Characteristics: