TrueTime API in Spanner
Learn about the TrueTime API methods and how it ensures external consistency.
TrueTime is a highly available distributed clock service. With TrueTime, applications can produce timestamps that increase monotonically. For example, if the generation of the timestamp
Spanner assigns timestamps to each transaction using the TrueTime API. The timestamp is the exact time Spanner considered the transaction to commit. Spanner's multi-version concurrency control guarantees the ordering of transactions on timestamps. It allows clients to execute consistent reads over the database, even when spread across different cloud regions, without blocking writes.
Let's dive into the details of the TrueTime API.
TrueTime API methods
As per
TrueTime API Methods
Method | Returns |
|
|
| True, if |
| True, if |
The argument t
is of the TTstamp
type. TrueTime reports an interval of time, TTinterval
, instead of an exact timestamp. The interval with bounded time uncertainty is represented directly in TrueTime. All endpoints of TTinterval
must be of the TTstamp
type. Upon calling TT.now()
, we'll get back a TTinterval
(earliest and latest values) that includes the precise moment that we want. The values are the earliest possible and latest possible timestamps. As per
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.