persist

package
v0.0.0-...-5a61565 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: MIT Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound         = errors.New("not found")
	ErrGone             = errors.New("gone")
	ErrReadOnly         = errors.New("read-only mode")
	ErrSnapshotReleased = errors.New("snapshot released")
	ErrIterReleased     = errors.New("iterator released")
	ErrClosed           = errors.New("closed")
	ErrVersionMismatch  = errors.New("version mismatch")
)

Common errors.

Functions

func UnsafeBytesToString

func UnsafeBytesToString(b []byte) string

UnsafeBytesToString converts []byte to string without a memcopy

func UnsafeStringToBytes

func UnsafeStringToBytes(s string) []byte

UnsafeStringToBytes converts strings to []byte without memcopy

func VersionOf

func VersionOf(data []byte) uint64

VersionOf calculates the version of the value to store

Types

type KeyValue

type KeyValue struct {
	Key   string
	Value Value
	// contains filtered or unexported fields
}

KeyValue represents an entry with key name

type Store

type Store interface {
	Put(string, *Value) error
	Get(string) (Value, error)
	FindByPrefix(string) ([]KeyValue, error)
	Delete(string) error
	Close() error
}

Store for values by key

func NewGoLevelDBStore

func NewGoLevelDBStore(cfg *viper.Viper) (Store, error)

NewGoLevelDBStore creates a new store backed by goleveldb

type Value

type Value struct {
	Value       []byte
	Version     uint64
	LastUpdated int64
	// contains filtered or unexported fields
}

Value returned from a persistence medium

func (*Value) DecodeMsg

func (z *Value) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Value) EncodeMsg

func (z *Value) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Value) MarshalMsg

func (z *Value) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Value) Msgsize

func (z *Value) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Value) UnmarshalMsg

func (z *Value) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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