Use cases where caching data is useful and where it should be transparent and long lived are covered by this.
PipeConfig pipeConfig = buildConfig()
SyncConfig syncConfig = new SyncConfig();
syncConfig.setType(SyncTypes.PeriodicReadOnly);
syncConfig.setExpiresIn(SyncConfig.24_HOURS);
pipeConfig.setSync(syncConfig);
Pipe<Schedule> schedulePipe = pipeline.pipe(pipeConfig);
schedulePipe.read(/*call back*/);
/*
This will check a SQL Store, notice there is no data, fetch the data, and store metadata about when it was fetched.
*/
//12 Hours later
schedulePipe.read(/*call back*/);
/*
This will check a SQL Store, notice there is data, notice it is inside of the expires time, and return it.
No call to the remote source will be made.
*/
//36 Hours later
schedulePipe.read(/*call back*/);
/*
This will check a SQL Store, notice there is data, notice it is stale, and refetch and refresh the data.
*/
Questions for consideration:
How will save/delete work? How will readWithFilter work? What happens if we have stale data and no internet connection? Should we include a job which fetches data in the background instead of checking when the call is made?