kvs

package
v0.0.0-...-ec3616b Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: 0BSD Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open[Schema any](db Database) *Schema

Types

type Database

type Database interface {
	Lookup(ctx context.Context, fmt Format, key, val any) (bool, error)
	Insert(ctx context.Context, fmt Format, key, val any) error
	Delete(ctx context.Context, fmt Format, key any) error
	Values(context.Context, *error, Format, Filter[any]) iter.Seq[func(any, any)]
}

type Filter

type Filter[K comparable] struct {
	Prefix K
	Cursor K
	Offset int
}

type Format

type Format string

type Map

type Map[K comparable, V any] struct {
	Lookup func(context.Context, K) (V, bool, error)
	Commit func(ctx context.Context, insert map[K]V, delete ...K) error
	Values func(context.Context, *error, Filter[K]) iter.Seq2[K, V]
}

func New

func New[K comparable, V any]() Map[K, V]

func (Map[K, V]) All

func (m Map[K, V]) All(ctx context.Context, err *error) iter.Seq2[K, V]

func (Map[K, V]) Del

func (m Map[K, V]) Del(ctx context.Context, key K) error

func (Map[K, V]) Get

func (m Map[K, V]) Get(ctx context.Context, key K) (V, error)

func (Map[K, V]) Set

func (m Map[K, V]) Set(ctx context.Context, key K, val V) error

Jump to

Keyboard shortcuts

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