kvstore

package
v0.0.0-...-529fe40 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GetOp opCode = 0
	SetOp opCode = 1
	DelOp opCode = 2
)

Variables

View Source
var (
	ErrConnNotOpened = errors.New("unable to open connection to the database")
	ErrKeyNotFound   = errors.New("key not found")
	ErrStopped       = errors.New("server has been stopped")
)
View Source
var (
	ErrTypeNotSupported = errors.New("type not supported")
)

Functions

func ConvertFromValue

func ConvertFromValue(val *KvValue) (any, error)

Types

type KvStore

type KvStore interface {
	Get(ctx context.Context, key string) (*KvValue, error)
	Set(ctx context.Context, key string, value *KvValue) error
}

type KvType

type KvType string
const (
	StringType  KvType = "S"
	Float64Type KvType = "F64"
	Float32Type KvType = "F32"
	Int32Type   KvType = "I32"
	Int64Type   KvType = "I64"
	BinaryType  KvType = "BLOB" // blob
	UnknownType KvType = "-"
)

type KvValue

type KvValue struct {
	Value []byte
	Type  KvType
}

func ConvertToValue

func ConvertToValue(val any) (*KvValue, error)

func KvBinary

func KvBinary(value []byte) *KvValue

func KvFloat32

func KvFloat32(val float32) *KvValue

func KvFloat64

func KvFloat64(val float64) *KvValue

func KvInt32

func KvInt32(val int32) *KvValue

func KvInt64

func KvInt64(val int64) *KvValue

func KvString

func KvString(value string) *KvValue

func (*KvValue) String

func (kv *KvValue) String() string

type SqliteStorage

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

func NewKvStore

func NewKvStore(fileName string) (*SqliteStorage, error)

func (*SqliteStorage) Close

func (s *SqliteStorage) Close() error

func (*SqliteStorage) Get

func (s *SqliteStorage) Get(ctx context.Context, key string) (*KvValue, error)

func (*SqliteStorage) Set

func (s *SqliteStorage) Set(ctx context.Context, key string, value *KvValue) error

Jump to

Keyboard shortcuts

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