Interface ReadOnlyTransaction
- All Superinterfaces:
AutoCloseable
,ReadContext
- All Known Subinterfaces:
BatchReadOnlyTransaction
Snapshot read-only transactions provide a simpler method than locking read-write transactions for doing several consistent reads. However, this type of transaction does not support writes.
Snapshot read-only transactions do not take locks. Instead, they work by choosing a Cloud Spanner timestamp, then executing all reads at that timestamp. Since they do not acquire locks, they do not block concurrent read-write transactions.
Unlike locking read-write transactions, snapshot read-only transactions never abort. They can
fail if the chosen read timestamp is garbage collected; however, the default garbage collection
policy is generous enough that most applications do not need to worry about this in practice. See
the class documentation of TimestampBound
for more details.
To execute a snapshot transaction, specify a TimestampBound
, which tells Cloud Spanner
how to choose a read timestamp.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.cloud.spanner.ReadContext
ReadContext.QueryAnalyzeMode
-
Method Summary
Modifier and TypeMethodDescriptioncom.google.cloud.Timestamp
Returns the timestamp chosen to perform reads and queries in this transaction.Methods inherited from interface com.google.cloud.spanner.ReadContext
analyzeQuery, close, executeQuery, executeQueryAsync, read, readAsync, readRow, readRowAsync, readRowUsingIndex, readRowUsingIndexAsync, readUsingIndex, readUsingIndexAsync
-
Method Details
-
getReadTimestamp
com.google.cloud.Timestamp getReadTimestamp()Returns the timestamp chosen to perform reads and queries in this transaction. The value can only be read after some read or query has either returned some data or completed without returning any data.
-