buntdb

package
v0.0.8-20250724 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

buntdb包:基于BuntDB的高性能内存缓存实现 提供键值存储、哈希表操作、队列操作和事务支持

BuntDB是一个快速的内存数据库,适用于需要高性能读写的场景 本包实现了Cache接口,提供统一的缓存操作API

主要特性: - 纯内存存储,读写性能极佳 - 支持持久化到文件 - 支持TTL过期 - 队列操作(FIFO/LIFO) - 哈希表操作 - 事务支持 - 线程安全

作者: gophertool

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBuntStore

func NewBuntStore(config config.Cache) (_interface.Cache, error)

Types

type BuntDb

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

BuntDb BuntDB缓存实现结构体

func (*BuntDb) BeginTx

func (b *BuntDb) BeginTx() (_interface.Tx, error)

func (*BuntDb) Close

func (b *BuntDb) Close()

Close 关闭数据库连接

func (*BuntDb) Delete

func (b *BuntDb) Delete(key string) error

func (*BuntDb) Exists

func (b *BuntDb) Exists(key string) (bool, error)

func (*BuntDb) Expire

func (b *BuntDb) Expire(key string, ttl time.Duration) error

func (*BuntDb) Get

func (b *BuntDb) Get(key string) (string, error)

Get 获取指定key的值 参数:

key - 键名

返回值:

string - 键对应的值
error - 操作错误,键不存在时返回ErrKeyNotFound

func (*BuntDb) HDel

func (b *BuntDb) HDel(key, field string) error

func (*BuntDb) HGet

func (b *BuntDb) HGet(key, field string) (string, error)

func (*BuntDb) HGetAll

func (b *BuntDb) HGetAll(key string) (map[string]string, error)

func (*BuntDb) HSet

func (b *BuntDb) HSet(key, field, value string, ttl time.Duration) error

func (*BuntDb) LPop

func (b *BuntDb) LPop(key string) (string, error)

LPop 弹出列表头部元素 参数:

key - 列表键名

返回值:

string - 弹出的元素值
error - 操作错误,列表为空时返回ErrKeyNotFound

func (*BuntDb) LPush

func (b *BuntDb) LPush(key string, value string) error

func (*BuntDb) Len

func (b *BuntDb) Len(key string) (int64, error)

func (*BuntDb) Pop

func (b *BuntDb) Pop(key string) (string, error)

func (*BuntDb) PopAll

func (b *BuntDb) PopAll(key string) ([]string, error)

func (*BuntDb) Push

func (b *BuntDb) Push(key string, value string) error

func (*BuntDb) RPop

func (b *BuntDb) RPop(key string) (string, error)

RPop 弹出列表尾部元素 参数:

key - 列表键名

返回值:

string - 弹出的元素值
error - 操作错误,列表为空时返回ErrKeyNotFound

func (*BuntDb) RPush

func (b *BuntDb) RPush(key string, value string) error

func (*BuntDb) Set

func (b *BuntDb) Set(key string, value string, ttl time.Duration) error

Jump to

Keyboard shortcuts

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