kv

package
v0.0.0-...-f66ea8c Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyNotFound = &errors.Error{Code: ecode.ErrKvNotFound, HTTPStatusCode: http.StatusContinue, Description: "Kv not found"}
)

Functions

func ApplyConfig

func ApplyConfig(cfg *IteratorConfig, opts ...IteratorOption)

func DoTransaction

func DoTransaction(store TransactionStore, ctx context.Context, f func(txn Transaction) error) error

Types

type Iterator

type Iterator interface {
	Seek(key []byte)
	Valid() bool
	Next()
	Key() []byte
	Value() []byte
	Close()
}

type IteratorConfig

type IteratorConfig struct {
	Prefix []byte
}

type IteratorOption

type IteratorOption interface {
	// contains filtered or unexported methods
}

func WithPrefix

func WithPrefix(prefix []byte) IteratorOption

WithPrefix returns an IteratorOption that sets the prefix for an iterator. This option configures the iterator to only access items that have the specified prefix. A prefix is a slice of bytes that the keys of items should start with in order to be included in the iteration.

type Store

type Store interface {
	Put(ctx context.Context, key []byte, val []byte) error
	Get(ctx context.Context, key []byte) ([]byte, error)
	Delete(ctx context.Context, key []byte) error
	NewIterator(opts ...IteratorOption) (Iterator, error)
	Close() error
}

type StoreSuite

type StoreSuite struct {
	suite.Suite
	Store Store
}

func (*StoreSuite) TestIterator

func (s *StoreSuite) TestIterator()

func (*StoreSuite) TestKV

func (s *StoreSuite) TestKV()

type TTLStoreSuite

type TTLStoreSuite struct {
	suite.Suite
	Store Store
	TTL   time.Duration
}

func (*TTLStoreSuite) TestKV

func (s *TTLStoreSuite) TestKV()

type Transaction

type Transaction interface {
	Put(ctx context.Context, key []byte, val []byte) error
	Get(ctx context.Context, key []byte) ([]byte, error)
	Delete(ctx context.Context, key []byte) error
	Commit(ctx context.Context) error
	Rollback() error
}

type TransactionStore

type TransactionStore interface {
	Store
	NewTransaction() (Transaction, error)
}

type TransactionSuite

type TransactionSuite struct {
	StoreSuite
	Store TransactionStore
}

func (*TransactionSuite) SetupTest

func (s *TransactionSuite) SetupTest()

func (*TransactionSuite) TestTransaction

func (s *TransactionSuite) TestTransaction()

func (*TransactionSuite) TestTransactionConflict

func (s *TransactionSuite) TestTransactionConflict()

func (*TransactionSuite) TestTransactionConsistency

func (s *TransactionSuite) TestTransactionConsistency()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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