Multiple data sources
Last updated
Last updated
Let's see how we can add multiple data sources and what happens when data is requested.
In this example we add two to Livebox instance. This is what happens when the client subscribes the observable.
We iterate the list of data sources and ask each one if they have data stored for key "get_users". Iteration is done by added order, so in the above example we first ask in-memory LRU data source and then disk persistent data source.
If no data source has data available instance is called to fetch data.
When a data source has available data, then call the data source validator to check if the data is still valid. Maybe the data is too old, or is not valid anymore for some other reason. If data is available and it's valid its emitted by the Observable.