tkv

package
v0.0.0-...-9dc1917 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsErrKeyNotFound

func IsErrKeyNotFound(err error) bool

Types

type Config

type Config struct {
	Logger         *slog.Logger
	BadgerLogLevel slog.Level
	Directory      string
	AppCtx         context.Context
}

type ErrCASFailed

type ErrCASFailed struct {
	Key string
}

ErrCASFailed is returned when a Compare-And-Swap operation fails because the expected value did not match the actual value.

func (*ErrCASFailed) Error

func (e *ErrCASFailed) Error() string

type ErrDataCorruption

type ErrDataCorruption struct {
	Key    string
	Reason string
}

func (*ErrDataCorruption) Error

func (e *ErrDataCorruption) Error() string

type ErrInternal

type ErrInternal struct {
	Err error
}

func (*ErrInternal) Error

func (e *ErrInternal) Error() string

func (*ErrInternal) Unwrap

func (e *ErrInternal) Unwrap() error

type ErrInvalidState

type ErrInvalidState struct {
	Key    string
	Reason string
}

ErrInvalidState is returned when an operation encounters data in an unexpected format.

func (*ErrInvalidState) Error

func (e *ErrInvalidState) Error() string

type ErrKeyExists

type ErrKeyExists struct {
	Key string
}

func (*ErrKeyExists) Error

func (e *ErrKeyExists) Error() string

type ErrKeyNotFound

type ErrKeyNotFound struct {
	Key string
}

func (*ErrKeyNotFound) Error

func (e *ErrKeyNotFound) Error() string

type TKV

type TKV interface {
	TKVDataHandler
	TKVCacheHandler
	TKVBatchHandler

	Close() error

	GetDataDB() *badger.DB
	GetCache() *badger.DB
}

func New

func New(config Config) (TKV, error)

type TKVBatchEntry

type TKVBatchEntry struct {
	Key   string
	Value string
}

type TKVBatchHandler

type TKVBatchHandler interface {
	BatchSet(entries []TKVBatchEntry) error
	BatchDelete(keys []string) error
}

type TKVCacheHandler

type TKVCacheHandler interface {
	CacheGet(key string) (string, error)
	CacheSet(key string, value string) error
	CacheDelete(key string) error

	CacheSetNX(key string, value string) error
	CacheCompareAndSwap(key string, oldValue, newValue string) error
	CacheIterate(prefix string, offset int, limit int, trimPrefix string) ([]string, error)
}

type TKVDataHandler

type TKVDataHandler interface {
	Get(key string) (string, error)
	Iterate(prefix string, offset int, limit int, trimPrefix string) ([]string, error)
	Set(key string, value string) error
	Delete(key string) error
	SetNX(key string, value string) error
	CompareAndSwap(key string, oldValue, newValue string) error

	BumpInteger(key string, delta int64) error
}

Jump to

Keyboard shortcuts

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