client

package
v0.0.0-...-8eef2bf Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
	ErrNewBatch = errors.New("new batch failed")
	ErrNewSnap  = errors.New("new snap failed")
)

Functions

func CopyBytes

func CopyBytes(b []byte) (copiedBytes []byte)

CopyBytes returns an exact copy of the provided bytes.

func NewClient

func NewClient(opt *Option) (*client, error)

Types

type Batch

type Batch struct {
	Writes []KeyValue
	// contains filtered or unexported fields
}

func (*Batch) Close

func (b *Batch) Close() error

func (*Batch) Delete

func (b *Batch) Delete(key []byte) error

Delete inserts the a key removal into the batch for later committing.

func (*Batch) Put

func (b *Batch) Put(key, value []byte) error

Put inserts the given value into the batch for later committing.

func (*Batch) Reset

func (b *Batch) Reset()

Reset resets the batch for reuse.

func (*Batch) ValueSize

func (b *Batch) ValueSize() int

ValueSize retrieves the amount of data queued up for writing.

func (*Batch) Write

func (b *Batch) Write() error

Write flushes any accumulated data to the memory database.

type Client

type Client interface {
	Get(key []byte) ([]byte, error)
	Put(key, value []byte) error
	Delete(key []byte) error
	Close() error
	Has(key []byte) (bool, error)
	NewBatch() (*Batch, error)
	NewIter(start, end []byte) (*Iterator, error)
	NewSnap() (*Snap, error)
	Sequence() (uint64, error)
}

type Iterator

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

func (*Iterator) Close

func (i *Iterator) Close() error

func (*Iterator) Error

func (i *Iterator) Error() error

func (*Iterator) Key

func (i *Iterator) Key() []byte

func (*Iterator) Next

func (i *Iterator) Next() bool

func (*Iterator) Value

func (i *Iterator) Value() []byte

type KeyValue

type KeyValue struct {
	Key    []byte
	Value  []byte
	Delete bool
}

type Option

type Option struct {
	Host string
	Port string
	Size int // client pool size
}

type Snap

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

func (*Snap) Get

func (s *Snap) Get(key []byte) ([]byte, error)

func (*Snap) Has

func (s *Snap) Has(key []byte) (bool, error)

func (*Snap) Release

func (s *Snap) Release() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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