kv

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package kv provide k/v storage by LevelDB

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNotFound indicates record was not found in db
	ErrNotFound = fmt.Errorf("kv: not found")
	// ErrForbidden indicates no access
	ErrForbidden = fmt.Errorf("kv: forbidden")
	// ErrTransfer indicates can't link to db
	ErrConnection = fmt.Errorf("kv: connect error")
	// ErrEncoding indicates an error occured while in/decoding
	ErrEncoding = fmt.Errorf("kv: encoding error")
	// ErrUnknown indicates an unknown error
	ErrUnknown = fmt.Errorf("kv: unknown error")
)

Functions

func Compact

func Compact() error

Compact storage

func Delete

func Delete(key []byte) error

Delete key/value

func Get

func Get(key []byte) ([]byte, error)

Get value of key

func Has

func Has(key []byte) (bool, error)

Has is used to check the existence of a key

func List

func List(start []byte, limit []byte) (list [][]byte)

List keys

func Put

func Put(key []byte, value []byte) error

Put key/value

Types

type Context

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

Context of kv client

func NewContext

func NewContext(name string) *Context

NewContext return a new Context of kv

Context was initialized at path that named `kv.name.path` in config file NewContext will return nil if no client found by name `kv.name.path`

func (*Context) Compact

func (c *Context) Compact() error

Compact storage

func (*Context) Delete

func (c *Context) Delete(key []byte) error

Delete key/value

func (*Context) Get

func (c *Context) Get(key []byte) ([]byte, error)

Get value of key

func (*Context) Has

func (c *Context) Has(key []byte) (bool, error)

Has is used to check the existence of a key

func (*Context) List

func (c *Context) List(start []byte, limit []byte) (list [][]byte)

List keys

func (*Context) Name added in v0.0.2

func (c *Context) Name() string

Name return name of context

func (*Context) Put

func (c *Context) Put(key []byte, value []byte) error

Put key/value

type Kver

type Kver interface {
	Name() (name string)
	Has(key []byte) (ok bool, err error)
	Get(key []byte) (value []byte, err error)
	Put(key []byte, value []byte) (err error)
	Delete(key []byte) (err error)
}

Kver provide key/value operates

Jump to

Keyboard shortcuts

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