kvdb

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KVEngineTypeLDB    = "leveldb"
	KVEngineTypeBadger = "badger"
)
View Source
const (
	StorageTypeSingle = "single"
	StorageTypeMulti  = "multi"
	StorageTypeCloud  = "cloud"
)

Variables

This section is empty.

Functions

func ErrNotFound

func ErrNotFound(err error) bool

ErrNotFound return true or false when key not found

func Register

func Register(name string, f NewStorageFunc)

Types

type Batch

type Batch interface {
	ValueSize() int
	Write() error
	Reset()
	Put(key []byte, value []byte) error
	Delete(key []byte) error
	PutIfAbsent(key []byte, value []byte) error
	Exist(key []byte) bool
}

Batch Batch操作的接口

type Database

type Database interface {
	Open(path string, options map[string]interface{}) error
	Put(key []byte, value []byte) error
	Get(key []byte) ([]byte, error)
	Has(key []byte) (bool, error)
	Delete(key []byte) error
	Close()
	NewBatch() Batch
	NewIteratorWithRange(start []byte, limit []byte) Iterator
	NewIteratorWithPrefix(prefix []byte) Iterator
}

Database KV数据库的接口

func CreateKVInstance

func CreateKVInstance(kvParam *KVParameter) (Database, error)

func NewTable

func NewTable(db Database, prefix string) Database

NewTable 基于前缀编码方式实现多表

type Iterator

type Iterator interface {
	Key() []byte
	Value() []byte
	Next() bool
	Prev() bool
	Last() bool
	First() bool
	Error() error
	Release()
}

Iterator NewIteratorXX操作后得到的迭代器

type KVParameter

type KVParameter struct {
	DBPath                string
	KVEngineType          string
	StorageType           string
	MemCacheSize          int
	FileHandlersCacheSize int
	OtherPaths            []string
	Options               map[string]interface{}
}

KVParameter structure for kv instance parameters

func (*KVParameter) GetDBPath

func (param *KVParameter) GetDBPath() string

GetDBPath return the value of DBPath

func (*KVParameter) GetFileHandlersCacheSize

func (param *KVParameter) GetFileHandlersCacheSize() int

GetFileHandlersCacheSize return the value of FileHandlersCacheSize

func (*KVParameter) GetKVEngineType

func (param *KVParameter) GetKVEngineType() string

GetKVEngineType return the value of KVEngineType

func (*KVParameter) GetMemCacheSize

func (param *KVParameter) GetMemCacheSize() int

GetMemCacheSize return the value of MemCacheSize

func (*KVParameter) GetOtherPaths

func (param *KVParameter) GetOtherPaths() []string

GetOtherPaths return the value of OtherPaths

func (*KVParameter) GetStorageType

func (param *KVParameter) GetStorageType() string

GetStorageType return the value of GetStorageType

type NewStorageFunc

type NewStorageFunc func(*KVParameter) (Database, error)

type QuickIterator

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

QuickIterator define the data structure of quick iterator

func NewQuickIterator

func NewQuickIterator(ldb Database, prefix []byte, middleKey []byte) *QuickIterator

NewQuickIterator new quick iterator instance

func (*QuickIterator) Error

func (qi *QuickIterator) Error() error

Error return err for quick iterator

func (*QuickIterator) Key

func (qi *QuickIterator) Key() []byte

Key get key by quick iterator

func (*QuickIterator) Next

func (qi *QuickIterator) Next() bool

Next if iterator finished

func (*QuickIterator) Release

func (qi *QuickIterator) Release()

Release release iterators of quick iterator

func (*QuickIterator) Value

func (qi *QuickIterator) Value() []byte

Value get value by quick iterator

Directories

Path Synopsis
badger wrapper plugin so
badger wrapper plugin so

Jump to

Keyboard shortcuts

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