db

package
v0.0.0-...-4167ae3 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *badger.DB

Functions

func Del

func Del(key []byte)

Del 删除Key

func Get

func Get(key []byte) (value []byte)

Get 根据Key获取Value

func Init

func Init()

func PrefixScanKeyValue

func PrefixScanKeyValue(prefix []byte, f func(key, value []byte) error)

func PrefixUpdateKey

func PrefixUpdateKey(prefix []byte, f func(key []byte) ([]byte, error))

func Set

func Set(key, value []byte, ttl ...time.Duration)

Set 设置键值对,ttl是超时时间(可选)

func Stop

func Stop()

func Update

func Update(key []byte, f func(oldValue []byte) []byte) (exists bool)

Update 查找并修改值,返回原先是否存在。若原先不存在,则f的参数为nil。若f的返回值为nil,表示不进行Update。若f的返回值为空byte数组,表示删除。

func UpdateWithTtl

func UpdateWithTtl(key []byte, f func(oldValue []byte) ([]byte, time.Duration)) (exists bool)

UpdateWithTtl 同 Update ,但是有一个ttl

Types

This section is empty.

Jump to

Keyboard shortcuts

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