txnkv

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a transactional client of TiKV server.

func NewClient

func NewClient(ctx context.Context, pdAddrs []string, config config.Config) (*Client, error)

NewClient creates a client with PD addresses.

func (*Client) Begin

func (c *Client) Begin(ctx context.Context) (*Transaction, error)

Begin creates a transaction for read/write.

func (*Client) BeginWithTS

func (c *Client) BeginWithTS(ctx context.Context, ts uint64) *Transaction

BeginWithTS creates a transaction which is normally readonly.

func (*Client) Close

func (c *Client) Close() error

Close stop the client.

func (*Client) GetTS

func (c *Client) GetTS(ctx context.Context) (uint64, error)

GetTS returns a latest timestamp.

type Transaction

type Transaction struct {
	// contains filtered or unexported fields
}

Transaction is a key-value transaction.

func (*Transaction) BatchGet

func (txn *Transaction) BatchGet(ctx context.Context, keys []key.Key) (map[string][]byte, error)

BatchGet gets a batch of values from TiKV server.

func (*Transaction) Commit

func (txn *Transaction) Commit(ctx context.Context) error

Commit commits the transaction operations to KV store.

func (*Transaction) DelOption

func (txn *Transaction) DelOption(opt kv.Option)

DelOption deletes an option.

func (*Transaction) Delete

func (txn *Transaction) Delete(k key.Key) error

Delete removes the entry for key k from kv store.

func (*Transaction) Get

func (txn *Transaction) Get(ctx context.Context, k key.Key) ([]byte, error)

Get implements transaction interface. kv.IsErrNotFound can be used to check the error is a not found error.

func (*Transaction) IsReadOnly

func (txn *Transaction) IsReadOnly() bool

IsReadOnly returns if there are pending key-value to commit in the transaction.

func (*Transaction) Iter

func (txn *Transaction) Iter(ctx context.Context, k key.Key, upperBound key.Key) (kv.Iterator, error)

Iter creates an Iterator positioned on the first entry that k <= entry's key. If such entry is not found, it returns an invalid Iterator with no error. It yields only keys that < upperBound. If upperBound is nil, it means the upperBound is unbounded. The Iterator must be closed after use.

func (*Transaction) IterReverse

func (txn *Transaction) IterReverse(ctx context.Context, k key.Key) (kv.Iterator, error)

IterReverse creates a reversed Iterator positioned on the first entry which key is less than k.

func (*Transaction) Len

func (txn *Transaction) Len() int

Len returns the count of key-value pairs in the transaction's memory buffer.

func (*Transaction) LockKeys

func (txn *Transaction) LockKeys(keys ...key.Key) error

LockKeys tries to lock the entries with the keys in KV store.

func (*Transaction) Rollback

func (txn *Transaction) Rollback() error

Rollback undoes the transaction operations to KV store.

func (*Transaction) Set

func (txn *Transaction) Set(k key.Key, v []byte) error

Set sets the value for key k as v into kv store.

func (*Transaction) SetOption

func (txn *Transaction) SetOption(opt kv.Option, val interface{})

SetOption sets an option with a value, when val is nil, uses the default value of this option.

func (*Transaction) Size

func (txn *Transaction) Size() int

Size returns the length (in bytes) of the transaction's memory buffer.

func (*Transaction) String

func (txn *Transaction) String() string

func (*Transaction) Valid

func (txn *Transaction) Valid() bool

Valid returns if the transaction is valid. A transaction becomes invalid after commit or rollback.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL