kv

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 3 Imported by: 0

README

kv

import "git.tcp.direct/tcp.direct/database/kv"

Documentation

type Key
type Key struct {}

Key represents a key in a key/value store.

func NewKey
func NewKey(data []byte) *Key

NewKey creates a new Key from a byte slice.

func (*Key) Bytes
func (k *Key) Bytes() []byte

Bytes returns the raw byte slice form of the Key.

func (*Key) Equal
func (k *Key) Equal(k2 *Key) bool

Equal determines if two keys are equal.

func (*Key) String
func (k *Key) String() string

String returns the string slice form of the Key.

type KeyValue
type KeyValue struct {
	Key   *Key
	Value *Value
}

KeyValue represents a key and a value from a key/value store.

func NewKeyValue
func NewKeyValue(k *Key, v *Value) *KeyValue

NewKeyValue creates a new KeyValue from a key and value.

func (*KeyValue) Equal
func (kv *KeyValue) Equal(kv2 *KeyValue) bool

Equal determines if two key/value pairs are equal.

func (*KeyValue) String
func (kv *KeyValue) String() string
type Value
type Value struct {}

Value represents a value in a key/value store.

func NewValue
func NewValue(data []byte) *Value

NewValue creates a new Value from a byte slice.

func (*Value) Bytes
func (v *Value) Bytes() []byte

Bytes returns the raw byte slice form of the Value.

func (*Value) Equal
func (v *Value) Equal(v2 *Value) bool

Equal determines if two values are equal.

func (*Value) String
func (v *Value) String() string

String returns the string slice form of the Value.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNonExistentKey added in v0.4.2

func IsNonExistentKey(err error) bool

IsNonExistentKey returns true if the error is a NonExistentKeyError. This is syntactic sugar.

func RegularizeKVError added in v0.4.2

func RegularizeKVError(key []byte, value []byte, err error) error

RegularizeKVError returns a regularized error for a key-value store. This exists because some key-value stores return nil for a value and nil for an error when a key does not exist.

Types

type Key

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

Key represents a key in a key/value store.

func NewKey

func NewKey(data []byte) Key

NewKey creates a new Key from a byte slice.

func (Key) Bytes

func (k Key) Bytes() []byte

Bytes returns the raw byte slice form of the Key.

func (Key) Equal

func (k Key) Equal(k2 Key) bool

Equal determines if two keys are equal.

func (Key) String

func (k Key) String() string

String returns the string slice form of the Key.

type KeyValue

type KeyValue struct {
	Key   Key
	Value Value
}

KeyValue represents a key and a value from a key/value store.

func NewKeyValue

func NewKeyValue(k Key, v Value) KeyValue

NewKeyValue creates a new KeyValue from a key and value.

func NewKeyValueFromBytes added in v0.4.2

func NewKeyValueFromBytes(key []byte, value []byte) KeyValue

func (KeyValue) Equal

func (kv KeyValue) Equal(kv2 KeyValue) bool

Equal determines if two key/value pairs are equal.

func (KeyValue) String

func (kv KeyValue) String() string

type NonExistentKeyError added in v0.4.2

type NonExistentKeyError struct {
	Key        []byte
	Underlying error
}

NonExistentKeyError is an error type for when a key does not exist or has no value. This allows us to maintain consistency in error handling across different key-value stores. See RegularizeKVError for more information.

func (*NonExistentKeyError) Error added in v0.4.2

func (neke *NonExistentKeyError) Error() string

func (*NonExistentKeyError) Unwrap added in v0.4.2

func (neke *NonExistentKeyError) Unwrap() error

Unwrap returns the underlying error, if any. This implements the errors.Wrapper interface.

type Value

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

Value represents a value in a key/value store.

func NewValue

func NewValue(data []byte) Value

NewValue creates a new Value from a byte slice.

func (Value) Bytes

func (v Value) Bytes() []byte

Bytes returns the raw byte slice form of the Value.

func (Value) Equal

func (v Value) Equal(v2 Value) bool

Equal determines if two values are equal.

func (Value) String

func (v Value) String() string

String returns the string slice form of the Value.

Jump to

Keyboard shortcuts

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