keyvalue

package
v1.1.45 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrKeyEmpty key is empty error
	ErrKeyEmpty = errors.New("key is empty")
	// ErrKeyNotFound key not found error
	ErrKeyNotFound = errors.New("key not found")
)

Functions

This section is empty.

Types

type KVMapStore

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

KVMapStore implements a non thread safe KVStore based on go maps

func NewKVMapStore

func NewKVMapStore() *KVMapStore

NewKVMapStore creates a KVMapStore

func (KVMapStore) Delete

func (kvms KVMapStore) Delete(key Key) error

Delete deletes the key from the map, or returns an error if the key is not found

func (*KVMapStore) Get

func (kvms *KVMapStore) Get(key Key) (Value, error)

Get returns the value associated with the key, or an error if the key does not exist

func (*KVMapStore) Set

func (kvms *KVMapStore) Set(key Key, value Value) error

Set adds or replaces the key / value pair in the map

type KVStore

type KVStore interface {
	// Set sets or replaces a key/value pair in the store
	Set(key Key, value Value) error

	// Get gets the value given the key
	Get(key Key) (Value, error)

	// Delete deletes a key, returns an error if the key don't exist
	Delete(key Key) error
}

KVStore is a simple interface for KeyValue stores

type Key

type Key []byte

Key is the type for a key

type Value

type Value []byte

Value is the type for a value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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