Documentation
¶
Overview ¶
badgerdb包:基于BadgerDB的高性能本地缓存实现 提供键值存储、哈希表操作、队列操作和事务支持
BadgerDB是一个高性能的LSM树Key-Value存储引擎,专为SSD优化设计 本包实现了Cache接口,提供统一的缓存操作API
主要特性: - 高性能读写操作,基于LSM树结构 - 支持TTL过期机制 - 队列操作(FIFO/LIFO) - 哈希表操作(通过复合键实现) - 事务支持(读写事务) - 线程安全的并发访问 - 自动垃圾回收和压缩 - 本地文件存储,无需外部依赖
使用场景: - 本地高性能缓存 - 嵌入式应用存储 - 单机应用的持久化缓存
作者: gophertool
Index ¶
- func NewBadgerStore(config config.Cache) (_interface.Cache, error)
- type BadgerDb
- func (b *BadgerDb) BeginTx() (_interface.Tx, error)
- func (b *BadgerDb) Close()
- func (b *BadgerDb) Delete(key string) error
- func (b *BadgerDb) Exists(key string) (bool, error)
- func (b *BadgerDb) Expire(key string, ttl time.Duration) error
- func (b *BadgerDb) Get(key string) (string, error)
- func (b *BadgerDb) HDel(key, field string) error
- func (b *BadgerDb) HGet(key, field string) (string, error)
- func (b *BadgerDb) HGetAll(key string) (map[string]string, error)
- func (b *BadgerDb) HSet(key, field, value string, ttl time.Duration) error
- func (b *BadgerDb) LPop(key string) (string, error)
- func (b *BadgerDb) LPush(key string, value string) error
- func (b *BadgerDb) Len(key string) (int64, error)
- func (b *BadgerDb) Pop(key string) (string, error)
- func (b *BadgerDb) PopAll(key string) ([]string, error)
- func (b *BadgerDb) Push(key string, value string) error
- func (b *BadgerDb) RPop(key string) (string, error)
- func (b *BadgerDb) RPush(key string, value string) error
- func (b *BadgerDb) Set(key string, value string, ttl time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBadgerStore ¶
func NewBadgerStore(config config.Cache) (_interface.Cache, error)
NewBadgerStore 创建BadgerDB缓存实例的工厂函数 参数:
config - 缓存配置
返回值:
Cache - 缓存接口实例 error - 创建错误
Types ¶
type BadgerDb ¶
type BadgerDb struct {
// contains filtered or unexported fields
}
BadgerDb BadgerDB缓存实现结构体
func (*BadgerDb) Get ¶
Get 获取指定key的值 参数:
key - 键名
返回值:
string - 键对应的值 error - 操作错误,键不存在时返回ErrKeyNotFound
Click to show internal directories.
Click to hide internal directories.