public interface DatabaseClient
Modifier and Type | Method and Description |
---|---|
ReadOnlyTransaction |
readOnlyTransaction()
Returns a read-only transaction context in which a multiple reads and/or queries can be
performed using
TimestampBound.strong() concurrency. |
ReadOnlyTransaction |
readOnlyTransaction(TimestampBound bound)
Returns a read-only transaction context in which a multiple reads and/or queries can be
performed.
|
TransactionRunner |
readWriteTransaction()
Returns a transaction runner for executing a single logical transaction with retries.
|
ReadContext |
singleUse()
Returns a context in which a single read can be performed using
TimestampBound.strong()
concurrency. |
ReadContext |
singleUse(TimestampBound bound)
Returns a context in which a single read can be performed.
|
ReadOnlyTransaction |
singleUseReadOnlyTransaction()
Returns a read-only transaction context in which a single read or query can be performed using
TimestampBound.strong() concurrency. |
ReadOnlyTransaction |
singleUseReadOnlyTransaction(TimestampBound bound)
Returns a read-only transaction context in which a single read or query can be performed.
|
Timestamp |
write(Iterable<Mutation> mutations)
Writes the given mutations atomically to the database.
|
Timestamp |
writeAtLeastOnce(Iterable<Mutation> mutations)
Writes the given mutations atomically to the database without replay protection.
|
Timestamp write(Iterable<Mutation> mutations) throws SpannerException
This method uses retries and replay protection internally, which means that the mutations are applied exactly once on success, or not at all if an error is returned, regardless of any failures in the underlying network. Note that if the call is cancelled or reaches deadline, it is not possible to know whether the mutations were applied without performing a subsequent database operation, but the mutations will have been applied at most once.
SpannerException
Timestamp writeAtLeastOnce(Iterable<Mutation> mutations) throws SpannerException
Since this method does not feature replay protection, it may attempt to apply mutations
more than once; if the mutations are not idempotent, this may lead to a failure
being reported when the mutation was applied once. For example, an insert may fail with ErrorCode.ALREADY_EXISTS
even though the row did not exist before this method was called. For
this reason, most users of the library will prefer to use write(Iterable)
instead.
However, writeAtLeastOnce()
requires only a single RPC, whereas write()
requires two RPCs (one of which may be performed in advance), and so this method may be
appropriate for latency sensitive and/or high throughput blind writing.
SpannerException
ReadContext singleUse()
TimestampBound.strong()
concurrency.ReadContext singleUse(TimestampBound bound)
bound
- the timestamp bound at which to perform the readReadOnlyTransaction singleUseReadOnlyTransaction()
TimestampBound.strong()
concurrency. This method differs from singleUse()
in
that the read timestamp used may be inspected after the read has returned data or finished
successfully.ReadOnlyTransaction singleUseReadOnlyTransaction(TimestampBound bound)
singleUse(TimestampBound)
in that the read timestamp used may be
inspected after the read has returned data or finished successfully.bound
- the timestamp bound at which to perform the readReadOnlyTransaction readOnlyTransaction()
TimestampBound.strong()
concurrency. All reads/queries will use the
same timestamp, and the timestamp can be inspected after any read/query has returned data or
finished successfully.ReadOnlyTransaction readOnlyTransaction(TimestampBound bound)
Note that the bounded staleness modes, TimestampBound.Mode.MIN_READ_TIMESTAMP
and
TimestampBound.Mode.MAX_STALENESS
, are not supported for multi-use read-only
transactions.
bound
- the timestamp bound at which to perform the readTransactionRunner readWriteTransaction()
Copyright © 2017 Google. All rights reserved.