kvstore

package
v1.87.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const Delimiter = '/'

Delimiter separates nested paths in storage.

Variables

View Source
var ErrEmptyKey = errs.Class("empty key")

ErrEmptyKey is returned when an empty key is used in Put or in CompareAndSwap.

View Source
var ErrKeyNotFound = errs.Class("key not found")

ErrKeyNotFound used when something doesn't exist.

Functions

func PutAll

func PutAll(ctx context.Context, store Store, items ...Item) (err error)

PutAll adds multiple values to the store.

Types

type Item

type Item struct {
	Key      Key
	Value    Value
	IsPrefix bool
}

Item returns Key, Value, IsPrefix.

func CloneItem

func CloneItem(item Item) Item

CloneItem creates a deep copy of item.

func (Item) Less

func (item Item) Less(b Item) bool

Less returns whether item should be sorted before b.

type Items

type Items []Item

Items keeps all Item.

func CloneItems

func CloneItems(items Items) Items

CloneItems creates a deep copy of items.

func (Items) GetKeys

func (items Items) GetKeys() Keys

GetKeys gets all the Keys in []Item and converts them to Keys.

func (Items) Len

func (items Items) Len() int

Len is the number of elements in the collection.

func (Items) Less

func (items Items) Less(i, k int) bool

Less reports whether the element with index i should sort before the element with index j.

func (Items) Swap

func (items Items) Swap(i, k int)

Swap swaps the elements with indexes i and j.

type Key

type Key []byte

Key is the type for the keys in a `Store`.

func CloneKey

func CloneKey(key Key) Key

CloneKey creates a copy of key.

func (Key) Equal

func (key Key) Equal(b Key) bool

Equal returns whether key and b are equal.

func (Key) IsZero

func (key Key) IsZero() bool

IsZero returns true if the key struct is a zero value.

func (Key) Less

func (key Key) Less(b Key) bool

Less returns whether key should be sorted before b.

func (Key) MarshalBinary

func (key Key) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface for the Key type.

func (Key) String

func (key Key) String() string

String implements the Stringer interface.

type Keys

type Keys []Key

Keys is the type for a slice of keys in a `Store`.

func (Keys) ByteSlices

func (keys Keys) ByteSlices() [][]byte

ByteSlices converts a `Keys` struct to a slice of byte-slices (i.e. `[][]byte`).

func (Keys) Strings

func (keys Keys) Strings() []string

Strings returns everything as strings.

type Store

type Store interface {
	// Put adds a value to store.
	Put(context.Context, Key, Value) error
	// Get gets a value to store.
	Get(context.Context, Key) (Value, error)
	// Delete deletes key and the value.
	Delete(context.Context, Key) error
	// Range iterates over all items in unspecified order.
	// The Key and Value are valid only for the duration of callback.
	Range(ctx context.Context, fn func(context.Context, Key, Value) error) error
	// Close closes the store.
	Close() error
}

Store describes key/value stores like redis and boltdb.

type Value

type Value []byte

Value is the type for the values in a `ValueValueStore`.

func CloneValue

func CloneValue(value Value) Value

CloneValue creates a copy of value.

func (Value) IsZero

func (value Value) IsZero() bool

IsZero returns true if the value struct is a zero value.

func (Value) MarshalBinary

func (value Value) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface for the Value type.

type Values

type Values []Value

Values is the type for a slice of Values in a `Store`.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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