/** * Returns a timestamp bound that will perform reads and queries at an exact staleness. The * timestamp is chosen soon after the read is started. * * <p>Guarantees that all writes that have committed more than the specified number of seconds ago * are visible. Because Cloud Spanner chooses the exact timestamp, this mode works even if the * client's local clock is substantially skewed from Cloud Spanner commit timestamps. * * <p>Useful for reading at nearby replicas without the distributed timestamp negotiation overhead * of {@link #ofMaxStaleness(long, TimeUnit)}. */ public static TimestampBound ofExactStaleness(long num, TimeUnit units) { checkStaleness(num); return new TimestampBound(Mode.EXACT_STALENESS, null, createDuration(num, units)); }
/** * Returns a timestamp bound that will perform reads and queries at a timestamp chosen to be at * most {@code num units} stale. This guarantees that all writes that have committed more than the * specified number of seconds ago are visible. Because Cloud Spanner chooses the exact timestamp, * this mode works even if the client's local clock is substantially skewed from Cloud Spanner * commit timestamps. * * <p>Useful for reading the freshest data available at a nearby replica, while bounding the * possible staleness if the local replica has fallen behind. * * <p>Note that this option can only be used in single-use reads and single-use read-only * transactions. */ public static TimestampBound ofMaxStaleness(long num, TimeUnit units) { checkStaleness(num); return new TimestampBound(Mode.MAX_STALENESS, null, createDuration(num, units)); }
/** * Returns a timestamp bound that will perform reads and queries at an exact staleness. The * timestamp is chosen soon after the read is started. * * <p>Guarantees that all writes that have committed more than the specified number of seconds ago * are visible. Because Cloud Spanner chooses the exact timestamp, this mode works even if the * client's local clock is substantially skewed from Cloud Spanner commit timestamps. * * <p>Useful for reading at nearby replicas without the distributed timestamp negotiation overhead * of {@link #ofMaxStaleness(long, TimeUnit)}. */ public static TimestampBound ofExactStaleness(long num, TimeUnit units) { checkStaleness(num); return new TimestampBound(Mode.EXACT_STALENESS, null, createDuration(num, units)); }
/** * Returns a timestamp bound that will perform reads and queries at a timestamp chosen to be at * most {@code num units} stale. This guarantees that all writes that have committed more than the * specified number of seconds ago are visible. Because Cloud Spanner chooses the exact timestamp, * this mode works even if the client's local clock is substantially skewed from Cloud Spanner * commit timestamps. * * <p>Useful for reading the freshest data available at a nearby replica, while bounding the * possible staleness if the local replica has fallen behind. * * <p>Note that this option can only be used in single-use reads and single-use read-only * transactions. */ public static TimestampBound ofMaxStaleness(long num, TimeUnit units) { checkStaleness(num); return new TimestampBound(Mode.MAX_STALENESS, null, createDuration(num, units)); }