mirror of https://github.com/tikv/website.git
address comments
Signed-off-by: pingyu <yuping@pingcap.com>
This commit is contained in:
parent
345a18ffa1
commit
9af2207a18
|
|
@ -140,7 +140,7 @@ v, err := snapshot.Get(context.TODO(), []byte("foo"))
|
||||||
// ... handle Get result ...
|
// ... handle Get result ...
|
||||||
```
|
```
|
||||||
|
|
||||||
Snapshot can also be extracted from a existing transaction.
|
Snapshot can also be extracted from an existing transaction.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
snapshot := txn.GetSnapshot()
|
snapshot := txn.GetSnapshot()
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ menu:
|
||||||
|
|
||||||
TiKV offers two APIs that you can interact with:
|
TiKV offers two APIs that you can interact with:
|
||||||
|
|
||||||
| API | Description | Atomicity | Usage scenarios |
|
| API | Description | Atomicity | Usage scenarios |
|
||||||
|:------------- |:-------------------------------------------------------------------------------- |:------------- |:------------------------------------------------------------------------------------ |
|
|:------------- |:------------------------------------------------------------------------------ |:------------- |:------------------------------------------------------------------------------------ |
|
||||||
| Raw | A low-level key-value API to interact directly with individual key-value pairs | Single key | Your application requires low latency and does not involve distributed transactions. |
|
| Raw | A low-level key-value API to interact directly with individual key-value pairs | Single key | Your application requires low latency and does not involve distributed transactions. |
|
||||||
| Transactional | A high-level key-value API to provide ACID semantics. | Multiple keys | Your application requires distributed transactions. |
|
| Transactional | A high-level key-value API to provide ACID semantics. | Multiple keys | Your application requires distributed transactions. |
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ The `txnkv` package provides a transactional API against TiKV cluster.
|
||||||
|
|
||||||
### Create Client
|
### Create Client
|
||||||
|
|
||||||
Information about a TiKV cluster can be found by the address of PD server. After starting a TiKV cluster successfully, we can use PD's address list to create a client to interact with it.
|
The topology of a TiKV cluster can be discovered by PD server. After starting a TiKV cluster successfully, we can use PD's address list to create a client to interact with it.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
import "github.com/tikv/client-go/v2/txnkv"
|
import "github.com/tikv/client-go/v2/txnkv"
|
||||||
|
|
@ -140,7 +140,7 @@ v, err := snapshot.Get(context.TODO(), []byte("foo"))
|
||||||
// ... handle Get result ...
|
// ... handle Get result ...
|
||||||
```
|
```
|
||||||
|
|
||||||
Snapshot can also be extracted from a existed transaction.
|
Snapshot can also be extracted from an existing transaction.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
snapshot := txn.GetSnapshot()
|
snapshot := txn.GetSnapshot()
|
||||||
|
|
@ -220,7 +220,7 @@ if err != nil {
|
||||||
|
|
||||||
### Batch Operations
|
### Batch Operations
|
||||||
|
|
||||||
`RawKV` also supports batch operations using batch. Note that since `RawKV` is not transaction guaranteed, we do not guarantee that all writes will succeed or fail at the same time when these keys are distributed across multiple regions.
|
`RawKV` also supports batch operations using batch. Note that since `RawKV` does not provide transaction semantic, we do not guarantee that all writes will succeed or fail at the same time when these keys are distributed across multiple regions.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
values, err := client.BatchGet(context.TODO(), [][]byte{[]byte("key1"), []byte("key2")})
|
values, err := client.BatchGet(context.TODO(), [][]byte{[]byte("key1"), []byte("key2")})
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@ menu:
|
||||||
|
|
||||||
TiKV offers two APIs that you can interact with:
|
TiKV offers two APIs that you can interact with:
|
||||||
|
|
||||||
| API | Description | Atomicity | Usage scenarios |
|
| API | Description | Atomicity | Usage scenarios |
|
||||||
|:------------- |:-------------------------------------------------------------------------------- |:------------- |:------------------------------------------------------------------------------------ |
|
|:------------- |:------------------------------------------------------------------------------ |:------------- |:------------------------------------------------------------------------------------ |
|
||||||
| Raw | A lower-level key-value API to interact directly with individual key-value pairs | Single key | Your application requires low latency and does not involve distributed transactions. |
|
| Raw | A low-level key-value API to interact directly with individual key-value pairs | Single key | Your application requires low latency and does not involve distributed transactions. |
|
||||||
| Transactional | A higher-level key-value API to provide ACID semantics. | Multiple keys | Your application requires distributed transactions. |
|
| Transactional | A high-level key-value API to provide ACID semantics. | Multiple keys | Your application requires distributed transactions. |
|
||||||
|
|
||||||
{{< warning >}}
|
{{< warning >}}
|
||||||
To use both the raw and transactional APIs in the same cluster, please enable [API V2](../../../concepts/explore-tikv-features/api-v2).
|
To use both the raw and transactional APIs in the same cluster, please enable [API V2](../../../concepts/explore-tikv-features/api-v2).
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue