vkv

package
v0.0.0-...-b178995 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Sep              = ':'
	FlagUnknown byte = iota
	FlagMetaBlob
	FlagVersion
	FlagKey
)
View Source
const KvType = "kv"

KvType for meta serialization

Variables

View Source
var ErrNotFound = errors.New("vkv: key not found")

Functions

func NextKey

func NextKey(key string) string

NextKey returns the next key for lexigraphical (key = NextKey(lastkey))

func NextVersionCursor

func NextVersionCursor(key string) string

func PrevKey

func PrevKey(key string) string

PextKey returns the next key for lexigraphical (key = PextKey(lastkey))

Types

type DB

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

func New

func New(path string) (*DB, error)

New creates a new database.

func (*DB) Close

func (db *DB) Close() error

func (*DB) Destroy

func (db *DB) Destroy() error

func (*DB) Get

func (db *DB) Get(key string, version int64) (*KeyValue, error)

func (*DB) GetMetaBlob

func (db *DB) GetMetaBlob(key string, version int64) (string, error)

func (*DB) Keys

func (db *DB) Keys(start, end string, limit int) ([]*KeyValue, string, error)

func (*DB) Put

func (db *DB) Put(kv *KeyValue) error

func (*DB) ReverseKeys

func (db *DB) ReverseKeys(start, end string, limit int) ([]*KeyValue, string, error)

func (*DB) SetMetaBlob

func (db *DB) SetMetaBlob(key string, version int64, hash string) error

func (*DB) Versions

func (db *DB) Versions(key string, start, end int64, limit int) (*KeyValueVersions, int64, error)

type KeyValue

type KeyValue struct {
	SchemaVersion int `msgpack:"_v"`

	Key     string `msgpack:"k,omitempty"`
	Version int64  `msgpack:"v"`
	Hash    []byte `msgpack:"h,omitempty"`
	Data    []byte `msgpack:"d,omitempty"`
}

func UnserializeBlob

func UnserializeBlob(blob []byte) (*KeyValue, error)

func (*KeyValue) Dump

func (kv *KeyValue) Dump() ([]byte, error)

Implements the `MetaData` interface

func (*KeyValue) HexHash

func (kv *KeyValue) HexHash() string

func (*KeyValue) SetHexHash

func (kv *KeyValue) SetHexHash(h string) error

func (*KeyValue) Type

func (kv *KeyValue) Type() string

Implements the `MetaData` interface

type KeyValueVersions

type KeyValueVersions struct {
	Key string `json:"key"`

	// FIXME(tsileo): turn this into a []*VkvEntry
	Versions []*KeyValue `json:"versions"`
}

KeyValueVersions holds the full history for a key value pair

Jump to

Keyboard shortcuts

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