kv

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrKeyNotFound is returned when the targeted key doesn't exist.
	ErrKeyNotFound = errors.New("key not found")

	// ErrKeyAlreadyExists is returned when the targeted key already exists.
	ErrKeyAlreadyExists = errors.New("key already exists")
)

Common errors returned by the engine.

Functions

This section is empty.

Types

type BatchSession

type BatchSession struct {
	Store *Store
	DB    *pebble.DB
	Batch *pebble.Batch
	// contains filtered or unexported fields
}

func (*BatchSession) Close

func (s *BatchSession) Close() error

func (*BatchSession) Commit

func (s *BatchSession) Commit() error

func (*BatchSession) Delete

func (s *BatchSession) Delete(k []byte) error

Delete a record by key. If the key doesn't exist, it doesn't do anything.

func (*BatchSession) DeleteRange

func (s *BatchSession) DeleteRange(start []byte, end []byte) error

DeleteRange deletes all keys in the given range. This implementation deletes all keys one by one to simplify the rollback.

func (*BatchSession) Exists

func (s *BatchSession) Exists(k []byte) (bool, error)

Exists returns whether a key exists and is visible by the current session.

func (*BatchSession) Get

func (s *BatchSession) Get(k []byte) ([]byte, error)

Get returns a value associated with the given key. If not found, returns ErrKeyNotFound.

func (*BatchSession) Insert

func (s *BatchSession) Insert(k, v []byte) error

Insert inserts a key-value pair. If it already exists, it returns ErrKeyAlreadyExists.

func (*BatchSession) Iterator

func (s *BatchSession) Iterator(opts *pebble.IterOptions) *pebble.Iterator

func (*BatchSession) Put

func (s *BatchSession) Put(k, v []byte) error

Put stores a key value pair. If it already exists, it overrides it.

type Options

type Options struct {
	RollbackSegmentNamespace int64
	MaxBatchSize             int
	MaxTransientBatchSize    int
}

type RollbackSegment

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

func NewRollbackSegment

func NewRollbackSegment(db *pebble.DB, namespace int64) *RollbackSegment

func (*RollbackSegment) Apply

func (s *RollbackSegment) Apply(b *pebble.Batch) error

func (*RollbackSegment) Clear

func (s *RollbackSegment) Clear(b *pebble.Batch) error

func (*RollbackSegment) EnqueueOp

func (s *RollbackSegment) EnqueueOp(k []byte, kvOp uint8)

func (*RollbackSegment) Rollback

func (s *RollbackSegment) Rollback() error

type Session

type Session interface {
	Commit() error
	Close() error
	// Insert inserts a key-value pair. If it already exists, it returns ErrKeyAlreadyExists.
	Insert(k, v []byte) error
	// Put stores a key-value pair. If it already exists, it overrides it.
	Put(k, v []byte) error
	// Get returns a value associated with the given key. If not found, returns ErrKeyNotFound.
	Get(k []byte) ([]byte, error)
	// Exists returns whether a key exists and is visible by the current session.
	Exists(k []byte) (bool, error)
	// Delete a record by key. If not found, returns ErrKeyNotFound.
	Delete(k []byte) error
	DeleteRange(start []byte, end []byte) error
	Iterator(opts *pebble.IterOptions) *pebble.Iterator
}

type SnapshotSession

type SnapshotSession struct {
	Store    *Store
	Snapshot *snapshot
	// contains filtered or unexported fields
}

func (*SnapshotSession) Close

func (s *SnapshotSession) Close() error

func (*SnapshotSession) Commit

func (s *SnapshotSession) Commit() error

func (*SnapshotSession) Delete

func (s *SnapshotSession) Delete(k []byte) error

Delete a record by key. If not found, returns ErrKeyNotFound.

func (*SnapshotSession) DeleteRange

func (s *SnapshotSession) DeleteRange(start []byte, end []byte) error

func (*SnapshotSession) Exists

func (s *SnapshotSession) Exists(k []byte) (bool, error)

Exists returns whether a key exists and is visible by the current session.

func (*SnapshotSession) Get

func (s *SnapshotSession) Get(k []byte) ([]byte, error)

Get returns a value associated with the given key. If not found, returns ErrKeyNotFound.

func (*SnapshotSession) Insert

func (s *SnapshotSession) Insert(k, v []byte) error

func (*SnapshotSession) Iterator

func (s *SnapshotSession) Iterator(opts *pebble.IterOptions) *pebble.Iterator

func (*SnapshotSession) Put

func (s *SnapshotSession) Put(k, v []byte) error

type Store

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

func NewStore

func NewStore(db *pebble.DB, opts Options) *Store

func (*Store) LockSharedSnapshot

func (s *Store) LockSharedSnapshot()

func (*Store) NewBatchSession

func (s *Store) NewBatchSession() *BatchSession

func (*Store) NewSnapshotSession

func (s *Store) NewSnapshotSession() *SnapshotSession

func (*Store) NewTransientSession

func (s *Store) NewTransientSession() *TransientSession

func (*Store) Rollback

func (s *Store) Rollback() error

func (*Store) UnlockSharedSnapshot

func (s *Store) UnlockSharedSnapshot()

type TransientSession

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

func (*TransientSession) Close

func (s *TransientSession) Close() error

func (*TransientSession) Commit

func (s *TransientSession) Commit() error

func (*TransientSession) Delete

func (s *TransientSession) Delete(k []byte) error

Delete a record by key. If not found, returns ErrKeyNotFound.

func (*TransientSession) DeleteRange

func (s *TransientSession) DeleteRange(start []byte, end []byte) error

func (*TransientSession) Exists

func (s *TransientSession) Exists(k []byte) (bool, error)

Exists returns whether a key exists and is visible by the current session.

func (*TransientSession) Get

func (s *TransientSession) Get(k []byte) ([]byte, error)

Get returns a value associated with the given key. If not found, returns ErrKeyNotFound.

func (*TransientSession) Insert

func (s *TransientSession) Insert(k, v []byte) error

func (*TransientSession) Iterator

func (s *TransientSession) Iterator(opts *pebble.IterOptions) *pebble.Iterator

func (*TransientSession) Put

func (s *TransientSession) Put(k, v []byte) error

Put stores a key value pair. If it already exists, it overrides it.

Jump to

Keyboard shortcuts

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