cache

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltCache

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

BoltCache 基于 bbolt 的持久化缓存实现 实现 core.CacheStore 接口 采用内存 + 磁盘双层存储:读取走内存,写入同步到内存并异步刷盘 异步刷盘操作通过单 goroutine 串行化,保证磁盘写入顺序与内存操作一致

func NewBoltCache

func NewBoltCache(cachePath string, bucketName ...string) (*BoltCache, error)

NewBoltCache 创建或打开基于 bbolt 的持久化缓存 cachePath: 缓存数据库文件路径,如 "/path/to/cache.db" bucketName: bbolt bucket 名称,默认为 "cache"

func (*BoltCache) Close

func (c *BoltCache) Close() error

Close 实现 core.CacheStore 接口

func (*BoltCache) Delete

func (c *BoltCache) Delete(key string) error

Delete 实现 core.CacheStore 接口

func (*BoltCache) Flush

func (c *BoltCache) Flush() error

Flush 实现 core.CacheStore 接口 同步等待所有挂起的异步操作完成,然后将当前内存快照全量刷盘

func (*BoltCache) Get

func (c *BoltCache) Get(key string, value any) error

Get 实现 core.CacheStore 接口

func (*BoltCache) Len

func (c *BoltCache) Len() int

Len 实现 core.CacheStore 接口

func (*BoltCache) Set

func (c *BoltCache) Set(key string, value any) error

Set 实现 core.CacheStore 接口

Jump to

Keyboard shortcuts

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