This is old and out-dated. Please see https://doc.replicache.dev/strategies/overview instead.

🌁 Overview

The Global Version Strategy is the same as the The Last-Modified Strategy except it uses a monotonic clock instead of a non-monotonic/wall clock.

It fixes the correctness issues with the Last-Modified Strategy, but at the cost of significant concurrency limits — write throughput to the server is limited to the concurrency of the monotonic clock implementation.

👩🏻‍🏫 How it Works

Setup

  1. Setup database as-per The Last-Modified Strategy. Instead of a LastModified field, add a Version field.
  2. Add a field to your database somewhere that stores a single integer. Call this LastVersion. Implement a NextVersion() function that increments and returns this counter. (Note: Some databases have a first-class feature for this).
  3. Call NextVersion() instead of Now() whenever updating the Version field of an entity.

On Pull

😓 Challenges

🌈 Variations

The same variations available to The Last-Modified Strategy apply here.

✍🏽 Examples

The integration guide sample app uses the Global Version Strategy. See: https://doc.replicache.dev/guide/remote-database.