kv

package
v0.0.0-...-06bcc1c Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KV

type KV interface {
	OpenCloser
	Simpler
	Scanner
	Sequencer
}

KV is the interface that groups the Simpler and Scanner interfaces.

type Lithium

type Lithium struct {
	sync.Mutex

	// Name of the root bucket.
	RootBucketKey []byte
	// contains filtered or unexported fields
}

Lithium .

func NewLithium

func NewLithium() *Lithium

NewLithium initializes a new Lithium instance.

func (*Lithium) Close

func (l *Lithium) Close() error

Close closes the kvdb file.

func (*Lithium) Delete

func (l *Lithium) Delete(key []byte) error

Delete deletes a key.

func (*Lithium) Get

func (l *Lithium) Get(key []byte) (dst []byte, err error)

Get read a key's value.

func (*Lithium) NextSequence

func (l *Lithium) NextSequence() (uint64, error)

NextSequence generates a new sequence.

func (*Lithium) Open

func (l *Lithium) Open(path string, mode os.FileMode, timeout time.Duration) (err error)

Open opens a kvdb file.

func (*Lithium) Put

func (l *Lithium) Put(key []byte, value []byte) (err error)

Put creates/updates a key/value pair.

func (*Lithium) Reopen

func (l *Lithium) Reopen() error

Reopen re-open a kvdb file.

func (*Lithium) Scan

func (l *Lithium) Scan(prefix []byte) (<-chan ScanEntry, func())

Scan scans all the key/value pairs.

type LithiumScanEntry

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

LithiumScanEntry indicates an entry of scanning.

func (LithiumScanEntry) Error

func (e LithiumScanEntry) Error() error

Error .

func (LithiumScanEntry) Pair

func (e LithiumScanEntry) Pair() ([]byte, []byte)

Pair means a pair of key/value.

type MockedKV

type MockedKV struct {
	sync.Mutex
	// contains filtered or unexported fields
}

MockedKV .

func NewMockedKV

func NewMockedKV() *MockedKV

NewMockedKV .

func (*MockedKV) Close

func (m *MockedKV) Close() error

Close .

func (*MockedKV) Delete

func (m *MockedKV) Delete(key []byte) (err error)

Delete .

func (*MockedKV) Get

func (m *MockedKV) Get(key []byte) (value []byte, err error)

Get .

func (*MockedKV) NextSequence

func (m *MockedKV) NextSequence() (nextSeq uint64, err error)

NextSequence .

func (*MockedKV) Open

Open .

func (*MockedKV) Put

func (m *MockedKV) Put(key, value []byte) (err error)

Put .

func (*MockedKV) Scan

func (m *MockedKV) Scan(prefix []byte) (<-chan ScanEntry, func())

Scan .

type MockedScanEntry

type MockedScanEntry struct {
	Err   error
	Key   string
	Value []byte
}

MockedScanEntry .

func (MockedScanEntry) Error

func (e MockedScanEntry) Error() error

Error .

func (MockedScanEntry) Pair

func (e MockedScanEntry) Pair() ([]byte, []byte)

Pair .

type OpenCloser

type OpenCloser interface {
	Open(path string, mode os.FileMode, timeout time.Duration) error
	Close() error
}

OpenCloser is the interface that groups the basic Open and Close methods.

type ScanEntry

type ScanEntry interface {
	Pair() (key []byte, value []byte)
	Error() error
}

ScanEntry is the interface that groups the basic Pair and Error methods.

type Scanner

type Scanner interface {
	Scan([]byte) (<-chan ScanEntry, func())
}

Scanner is the interface that wraps the basic Scan method.

type Sequencer

type Sequencer interface {
	NextSequence() (ID uint64, err error)
}

Sequencer is the interface that wraps the basic NextSequence method.

type Simpler

type Simpler interface {
	Put([]byte, []byte) error
	Get([]byte) ([]byte, error)
	Delete([]byte) error
}

Simpler is the interface that groups the basic Put, Get and Delete methods.

Jump to

Keyboard shortcuts

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