kv

package module
v0.0.0-...-12e1fef Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: MIT Imports: 4 Imported by: 0

README

go-kv CI godoc goreportcard

Go module to generically interact with key/value stores in the spirit of GoCloud.

install

go get github.com/frantjc/go-kv

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCodec = JSON{}

Functions

func Register

func Register(opener URLOpener, scheme string, schemes ...string)

Types

type Codec

type Codec interface {
	// Marshal encodes a Go value to a slice of bytes.
	Marshal(v any) ([]byte, error)
	// Unmarshal decodes a slice of bytes into a Go value.
	Unmarshal(data []byte, v any) error
}

type JSON

type JSON struct{}

JSON encodes/decodes Go values to/from JSON.

func (JSON) Marshal

func (c JSON) Marshal(v any) ([]byte, error)

Marshal encodes a Go value to JSON.

func (JSON) Unmarshal

func (c JSON) Unmarshal(data []byte, v any) error

Unmarshal decodes a JSON value into a Go value.

type Store

type Store interface {
	Set(context.Context, string, any) error
	Get(context.Context, string, any) (bool, error)
	Delete(context.Context, string) error
	Close() error
}

func Open

func Open(ctx context.Context, s string) (Store, error)

type URLOpener

type URLOpener interface {
	Open(context.Context, *url.URL) (Store, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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