memkv

package
v3.0.15 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package memkv implements an in-memory key/value store with same API surface as "github.com/kelseyhightower/memkv".

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotExist   = errors.New("key does not exist")
	ErrBadPattern = path.ErrBadPattern
)

Functions

func FillKvMap

func FillKvMap(kvMap map[string]string, data interface{})

FillKvMap will fill the supplied kvMap with values from data.

func IsBadPattern

func IsBadPattern(err error) bool

func IsNotExists

func IsNotExists(err error) bool

func NewKeyError

func NewKeyError(key string, err error) error

func Walk

func Walk(callback func(key []string, value interface{}), data interface{})

Walk will recursively iterate over all the nodes of data calling callback for each node.

Types

type KVPair

type KVPair struct {
	Key   string
	Value string
}

type KVPairs

type KVPairs []KVPair

func (KVPairs) Len

func (ks KVPairs) Len() int

func (KVPairs) Less

func (ks KVPairs) Less(i, j int) bool

func (KVPairs) Swap

func (ks KVPairs) Swap(i, j int)

type KeyError

type KeyError struct {
	Key string
	Err error
}

func (KeyError) Error

func (e KeyError) Error() string

func (KeyError) Unwrap

func (e KeyError) Unwrap() error

type Option

type Option func(s *Store)

func WithKvMap

func WithKvMap(kv map[string]string) Option

func WithMap

func WithMap(data interface{}) Option

type Store

type Store struct {
	FuncMap map[string]interface{}
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) Store

func (Store) Del

func (s Store) Del(key string)

func (Store) Exists

func (s Store) Exists(key string) bool

func (Store) Get

func (s Store) Get(key string) (KVPair, error)

func (Store) GetAll

func (s Store) GetAll(pattern string) (KVPairs, error)

func (Store) GetAllValues

func (s Store) GetAllValues(pattern string) ([]string, error)

func (Store) GetValue

func (s Store) GetValue(key string, defaultValue ...string) (string, error)

func (Store) List

func (s Store) List(filePath string) []string

func (Store) ListDir

func (s Store) ListDir(filePath string) []string

func (Store) Purge

func (s Store) Purge()

func (Store) Set

func (s Store) Set(key string, value string)

func (Store) ToKvMap

func (s Store) ToKvMap() map[string]string

ToKvMap will return a one-level map of key value pairs where the key is a / separated path of subkeys.

Jump to

Keyboard shortcuts

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