Skip to content

Instantly share code, notes, and snippets.

@secondsun
Last active December 30, 2015 01:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save secondsun/e6552abfbf51ed915d92 to your computer and use it in GitHub Desktop.
Save secondsun/e6552abfbf51ed915d92 to your computer and use it in GitHub Desktop.

Periodic Read Only Update

Use cases where caching data is useful and where it should be transparent and long lived are covered by this.

Usage proposal: Reading a schedule (Android)

  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?

Use Case Push/Poll Realtime Server APIs Used
Periodic Read Only Update Poll N Any legacy Pipelines, Authentication, Stores
Real Time Read Only Update Push Y(ish) Legacy + Updates for Unified Push Unified Push, Store
Simple Settings Sync Push Y(ish) Legacy + Updates for Unified Push + Updates for conflict mgmt Pipelines, Authentication, UnifiedPush, Store
Real Time Text Sync Push Y Needs lots of custom code, vert.x realtime component UnifiedPush, Store
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment