Interface ReadOnlyTransaction
-
- All Superinterfaces:
AutoCloseable
,ReadContext
- All Known Subinterfaces:
BatchReadOnlyTransaction
public interface ReadOnlyTransaction extends ReadContext
A transaction type that provides guaranteed consistency across several reads, but does not allow writes. Snapshot read-only transactions can be configured to read at timestamps in the past. Snapshot read-only transactions do not need to be committed.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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description com.google.cloud.Timestamp
getReadTimestamp()
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
-
-