statusdb

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DbShard

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

DbShard 数据库分片,每个分片有自己的锁

type Item

type Item struct {
	Domain      string    // 查询域名
	Dns         string    // 查询dns
	Time        time.Time // 发送时间
	Retry       int       // 重试次数
	DomainLevel int       // 域名层级
}

type StatusDb

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

StatusDb 使用分片锁实现的高性能状态数据库

func CreateMemoryDB

func CreateMemoryDB() *StatusDb

CreateMemoryDB 创建一个内存数据库

func (*StatusDb) Add

func (r *StatusDb) Add(domain string, tableData Item)

Add 添加一个项

func (*StatusDb) Close

func (r *StatusDb) Close()

Close 关闭数据库

func (*StatusDb) Del

func (r *StatusDb) Del(domain string)

Del 删除一个项

func (*StatusDb) Get

func (r *StatusDb) Get(domain string) (Item, bool)

Get 获取一个项

func (*StatusDb) Length

func (r *StatusDb) Length() int64

Length 获取元素总数

func (*StatusDb) Scan

func (r *StatusDb) Scan(f func(key string, value Item) error)

Scan 遍历所有元素,优化并行性能

func (*StatusDb) Set

func (r *StatusDb) Set(domain string, tableData Item)

Set 设置一个项

func (*StatusDb) SetExpiration

func (r *StatusDb) SetExpiration(d time.Duration)

SetExpiration 设置条目过期时间

Jump to

Keyboard shortcuts

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