kv

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package kv provides a simple key-value library

Index

Constants

This section is empty.

Variables

View Source
var ErrNxKey = errors.New("key does not exist")

ErrNxKey error is returned when key does not exist

Functions

This section is empty.

Types

type List

type List struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

List provides key-value storage and a sync mutex

func NewList

func NewList() *List

NewList returns a new List

func (*List) Get

func (k *List) Get(key string, _ []byte) (string, []byte, error)

Get returns the value associated with provided key or ErrNxKey

func (*List) IsEmpty

func (k *List) IsEmpty() bool

IsEmpty returns true if k is empty

func (*List) Keys

func (k *List) Keys() []string

Keys returns a list of the keys

func (*List) Serialize

func (k *List) Serialize() []byte

Serialize flattens the key-values into a byte slice

func (*List) Set

func (k *List) Set(key string, value []byte) (string, []byte, error)

Set stores the value associated with key

func (*List) Values

func (k *List) Values() [][]byte

Values returns a list of the values

Jump to

Keyboard shortcuts

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