db

package
v0.0.0-...-5b18574 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBoltDBClientName = "default"

Variables

View Source
var BoltDBClients = make(map[string]*BoltDB)

Functions

func InitBoltDBClient

func InitBoltDBClient(clientName string, dbPath string) error

Types

type BoltDB

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

BoltDB 封装了bbolt数据库连接和操作

func GetBoltDBClient

func GetBoltDBClient(name string) *BoltDB

func NewBoltDB

func NewBoltDB(dbPath string) (*BoltDB, error)

NewBoltDB 创建一个新的BoltDB实例

func (*BoltDB) ClearBucket

func (b *BoltDB) ClearBucket(bucketName string) error

ClearBucket 清空指定bucket中的所有数据

func (*BoltDB) Close

func (b *BoltDB) Close() error

Close 关闭数据库连接

func (*BoltDB) Count

func (b *BoltDB) Count(bucketName string) (int, error)

Count 返回指定bucket中的键值对数量

func (*BoltDB) CreateBucket

func (b *BoltDB) CreateBucket(bucketName string) error

CreateBucket 创建一个新的bucket

func (*BoltDB) CreateBucketIfNotExists

func (b *BoltDB) CreateBucketIfNotExists(bucketName string) error

CreateBucketIfNotExists 如果bucket不存在则创建

func (*BoltDB) Delete

func (b *BoltDB) Delete(bucketName string, key string) error

Delete 从指定bucket中删除键值对

func (*BoltDB) DeleteBucket

func (b *BoltDB) DeleteBucket(bucketName string) error

DeleteBucket 删除一个bucket

func (*BoltDB) Exists

func (b *BoltDB) Exists(bucketName string, key string) (bool, error)

Exists 检查指定bucket中的键是否存在

func (*BoltDB) ForEach

func (b *BoltDB) ForEach(bucketName string, fn func(string, []byte) error) error

ForEach 遍历指定bucket中的所有键值对

func (*BoltDB) Get

func (b *BoltDB) Get(bucketName string, key string) ([]byte, error)

Get 从指定bucket中获取值

func (*BoltDB) GetAll

func (b *BoltDB) GetAll(bucketName string) (map[string][]byte, error)

GetAll 获取指定bucket中的所有键值对

func (*BoltDB) Put

func (b *BoltDB) Put(bucketName string, key string, value []byte) error

Put 在指定bucket中存储键值对

Jump to

Keyboard shortcuts

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