rawkv

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2021 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMaxScanLimitExceeded is returned when the limit for rawkv Scan is to large.
	ErrMaxScanLimitExceeded = errors.New("limit should be less than MaxRawKVScanLimit")
)

Functions

This section is empty.

Types

type Client

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

Client is a rawkv client of TiKV server which is used as a key-value storage, only GET/PUT/DELETE commands are supported.

func NewClient

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

NewClient creates a client with PD cluster addrs.

func (*Client) BatchDelete

func (c *Client) BatchDelete(ctx context.Context, keys [][]byte) error

BatchDelete deletes key-value pairs from TiKV.

func (*Client) BatchGet

func (c *Client) BatchGet(ctx context.Context, keys [][]byte) ([][]byte, error)

BatchGet queries values with the keys.

func (*Client) BatchPut

func (c *Client) BatchPut(ctx context.Context, keys, values [][]byte, options ...PutOption) error

BatchPut stores key-value pairs to TiKV.

func (*Client) Close

func (c *Client) Close() error

Close closes the client.

func (*Client) ClusterID

func (c *Client) ClusterID() uint64

ClusterID returns the TiKV cluster ID.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, key []byte) error

Delete deletes a key-value pair from TiKV.

func (*Client) DeleteRange

func (c *Client) DeleteRange(ctx context.Context, startKey []byte, endKey []byte) error

DeleteRange deletes all key-value pairs in a range from TiKV

func (*Client) Get

func (c *Client) Get(ctx context.Context, key []byte) ([]byte, error)

Get queries value with the key. When the key does not exist, it returns `nil, nil`.

func (*Client) GetKeyTTL

func (c *Client) GetKeyTTL(ctx context.Context, key []byte) (*uint64, error)

Get queries value with the key. When the key does not exist, it returns `nil, nil`.

func (*Client) Put

func (c *Client) Put(ctx context.Context, key, value []byte, options ...PutOption) error

Put stores a key-value pair to TiKV.

func (*Client) ReverseScan

func (c *Client) ReverseScan(ctx context.Context, startKey, endKey []byte, limit int, options ...ScanOption) (keys [][]byte, values [][]byte, err error)

ReverseScan queries continuous kv pairs in range [endKey, startKey), up to limit pairs. Direction is different from Scan, upper to lower. If endKey is empty, it means unbounded. If you want to include the startKey or exclude the endKey, append a '\0' to the key. For example, to scan (endKey, startKey], you can write: `ReverseScan(append(startKey, '\0'), append(endKey, '\0'), limit)`. It doesn't support Scanning from "", because locating the last Region is not yet implemented.

func (*Client) Scan

func (c *Client) Scan(ctx context.Context, startKey, endKey []byte, limit int, options ...ScanOption) (keys [][]byte, values [][]byte, err error)

Scan queries continuous kv pairs in range [startKey, endKey), up to limit pairs. If endKey is empty, it means unbounded. If you want to exclude the startKey or include the endKey, append a '\0' to the key. For example, to scan (startKey, endKey], you can write: `Scan(ctx, append(startKey, '\x00'), append(endKey, '\x00'), limit)`.

type PutOption

type PutOption struct {
	TTL uint64
}

PutOptions is used to provide additional information for put operation.

type ScanOption

type ScanOption struct {
	KeyOnly bool // if true, the result will only contains keys
}

ScanOption is used to provide additional information for scaning operation.

func DefaultScanOption

func DefaultScanOption() ScanOption

Jump to

Keyboard shortcuts

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