kv

package module
v0.0.0-...-7782e6b Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

README

Golang-kv

Bundle embedded databases with fixed api https://pkg.go.dev/github.com/ucwong/golang-kv

Interfaces

type Bucket interface {
	Get(k []byte) []byte
	Set(k, v []byte) error
	Del(k []byte) error
	Prefix(k []byte) [][]byte
	Suffix(k []byte) [][]byte
	Scan() [][]byte
	Range(start, limit []byte) [][]byte
	SetTTL(k, v []byte, expire time.Duration) error
	Close() error

	// BatchSet write & flush
	BatchSet(kvs map[string][]byte) error
	
	Name() string
}

used by

import "github.com/ucwong/golang-kv"

...

badger := kv.Badger("")
defer badger.Close()
badger.Set([]byte("x"), []byte("y")))
v := badger.Get([]byte("x"))
vs := badger.Prefix([]byte("x"))

...

bolt := kv.Bolt("")
defer bolt.Close()

bolt.setTTL([]byte("k"), []byte("v"), time.Second)

...

ldb := kv.LevelDB("")
defer ldb.Close()

...

peb := kv.Pebble("")
defer peb.Close()

...

nut := kv.NutsDB("")
defer nut.Close()
...

Test

make test

Repobeats

Alt

How to choose database engine

image

image

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket interface {
	Get(k []byte) []byte
	Set(k, v []byte) error
	Del(k []byte) error
	Prefix(k []byte) [][]byte
	Suffix(k []byte) [][]byte
	Scan() [][]byte
	Range(start, limit []byte) [][]byte
	SetTTL(k, v []byte, expire time.Duration) error
	Close() error

	// BatchSet write & flush
	BatchSet(kvs map[string][]byte) error

	Name() string
}

func Badger

func Badger(path string, opt ...badger.BadgerOption) Bucket

func Bolt

func Bolt(path string, opt ...bolt.BoltOption) Bucket

func LevelDB

func LevelDB(path string, opt ...leveldb.LevelDBOption) Bucket

func NutsDB

func NutsDB(path string, opt ...nutsdb.NutsdbOption) Bucket

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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