unique

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultOptions

func DefaultOptions() *pebble.Options

DefaultOptions returns the default options of pebble kv store. ref: https://github.com/cockroachdb/cockroach/blob/master/pkg/storage/pebble.go#L445-L498

func SaveSequence

func SaveSequence(store IDStore, key []byte, seq uint32) error

SaveSequence persists current sequence value into store with key.

Types

type IDStore

type IDStore interface {
	io.Closer

	// Get returns the value by given key, if not exist return false.
	Get(key []byte) ([]byte, bool, error)
	// Put puts the value into store by given key.
	Put(key, val []byte) error
	// Merge puts the value into store by given key, if the key exist, will merge value in background.
	Merge(key, val []byte) error
	// Delete deletes the value by given key.
	Delete(key []byte) error
	// IterKeys iterates the key list by given prefix, returns the key list.
	IterKeys(prefix []byte, limit int) (rs [][]byte, err error)
	// Flush flushes the memory table data under pebble db.
	Flush() error
}

IDStore represents unique id store for LinDB's metadata.

func NewIDStore

func NewIDStore(path string) (IDStore, error)

NewIDStore creates an IDStore instance.

type Sequence

type Sequence interface {
	// HasNext checks if it has sequence in cache.
	HasNext() bool
	// Next returns next sequence from cache.
	Next() uint32
	// Current returns current sequence from cache.
	Current() uint32
	// Limit sets new limit value.
	Limit(limit uint32)
}

Sequence represents allocate sequence with batch cache, reduces write operations. NOTICE: not thread safe.

func NewSequence

func NewSequence(val, limit uint32) Sequence

NewSequence creates a Sequence instance.

Jump to

Keyboard shortcuts

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