doleveldb

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: MIT Imports: 3 Imported by: 0

README

Doleveldb 搞定文件存储DB

基于goleveldb封装的键值数据库

使用说明

//初始化
ctx, _ := context.WithCancel(context.Background())
err := NewDoleveldb(ctx, ".sys/data")
if err != nil {
    t.Errorf(err.Error())
}

//新增key
err = Put("foo", "bar")
if err != nil {
    t.Errorf(err.Error())
}
t.Log("success Put.")

//获取key
res, err := Get("foo")
if err != nil {
    t.Errorf(err.Error())
}
t.Log("Get foo: ", res)

//删除key
err = Delete("foo")
if err != nil {
    t.Errorf(err.Error())
}
t.Log("success Delete.")

//如果需要获取DB
doleveldb.DB
测试示例
参阅 doleveldb_test.go

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DB *leveldb.DB
)

Functions

func Delete

func Delete(key string) error

删除key

func Get

func Get(key string) (string, error)

获取key

func NewDoleveldb

func NewDoleveldb(ctx context.Context, path string) error

初始化leveldb

func Put

func Put(key, val string) error

新增key

Types

This section is empty.

Jump to

Keyboard shortcuts

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