kdb

package module
v0.0.0-...-4d25b84 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2018 License: MIT Imports: 10 Imported by: 2

README

kdb

KDB是基于leveldb封装的简便数据库 KDB会提供类似于redis接口的操作

example

cfg := kdb.DefaultConfig()
cfg.InitKdb()
db := cfg.GetDb()

k := db.KHash([]byte("hello"))
k.Set([]byte("d"), []byte("f"))

for i := 0; i < 1000; i++ {
    name := fmt.Sprintf("hello%d", i)
    fmt.Println(name)
    k1 := db.KHash([]byte(name))
    k1.Set([]byte("d"), []byte("f"))
}

db.ScanAll(func(key, value []byte) error {
    fmt.Println(string(key), string(value))
    return nil
})

Documentation

Index

Constants

View Source
const Version = 0.1

Variables

This section is empty.

Functions

func DefaultConfig

func DefaultConfig() *config

Types

type IKDB

type IKDB interface {
	KHashExist(name []byte) (bool, error)
	KHash(name []byte) IKHash
	Close() error
	KHashNames() (names chan string, err error)
	ScanAll(fn func(key, value []byte)) error
}

type IKHBatch

type IKHBatch interface {
	Set(key, value []byte) error
	Get(key []byte) ([]byte, error)
	MDel(keys ...[]byte) error
	Exist(key []byte) (bool, error)
	PopRandom(n int, fn func(key, value []byte) error) error
	Pop(fn func(key, value []byte) error) error
	PopN(n int, fn func(key, value []byte) error) error
	Map(fn func(key, value []byte) ([]byte, error)) error
	GetSet(key, value []byte) (val []byte, err error)
	Range(fn func(key, value []byte) error) error
	Reverse(fn func(key, value []byte) error) error
	Random(n int, fn func(key, value []byte) error) error
}

type IKHash

type IKHash interface {
	Get(key []byte) ([]byte, error)
	Set(key, value []byte) error
	MSet(kv ...KV) error
	Del(key ...[]byte) error
	Exist(key []byte) (bool, error)
	Drop() error
	Len() (int, error)
	PopRandom(n int, fn func(key, value []byte) error) error
	Pop(fn func(key, value []byte) error) error
	PopN(n int, fn func(key, value []byte) error) error
	Range(fn func(key, value []byte) error) error
	Reverse(fn func(key, value []byte) error) error
	Map(fn func(key, value []byte) ([]byte, error)) error
	Union(otherNames ...[]byte) error
	WithBatch(fn func(b IKHBatch) error) error
}

type KV

type KV struct {
	Key   []byte
	Value []byte
	Error error
}

func (*KV) IsErr

func (kv *KV) IsErr() bool

Jump to

Keyboard shortcuts

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