public interface ReadOnlyTransaction extends ReadContext
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.
ReadContext.QueryAnalyzeMode
Modifier and Type | Method and Description |
---|---|
Timestamp |
getReadTimestamp()
Returns the timestamp chosen to perform reads and queries in this transaction.
|
analyzeQuery, close, executeQuery, read, readRow, readRowUsingIndex, readUsingIndex
Timestamp getReadTimestamp()
Copyright © 2019 Google LLC. All rights reserved.