修改成redis

This commit is contained in:
2026-04-20 18:26:54 +08:00
parent e944a25e56
commit a9cb0b2481
17 changed files with 2408 additions and 933 deletions
+6 -6
View File
@@ -21,7 +21,7 @@ import (
// Runner 管理反向链接计算循环。
type Runner struct {
db *storage.DB
store *storage.RedisStoreV2
storagePath string // 存储根目录(用于写入 prosper.json
mu sync.Mutex
running bool // 是否正在计算中
@@ -31,8 +31,8 @@ type Runner struct {
}
// New 创建一个 Runner 实例。
func New(db *storage.DB, storagePath string) *Runner {
return &Runner{db: db, storagePath: storagePath}
func New(store *storage.RedisStoreV2, storagePath string) *Runner {
return &Runner{store: store, storagePath: storagePath}
}
// Status 返回反链计算器的当前状态快照。
@@ -179,7 +179,7 @@ func (r *Runner) collectStats() *siteStats {
serverCount: make(map[string]int),
}
_ = r.db.ForEachSite(func(host string, info *storage.SiteInfo) error {
_ = r.store.ForEachSite(func(host string, info *storage.SiteInfo) error {
super := superDomain(host)
stats.subdomainCount[super]++
@@ -235,7 +235,7 @@ func (r *Runner) aggregate(filter func(*storage.SiteInfo) bool, stats *siteStats
pruneThreshold := 0.02
i := 0
_ = r.db.ForEachSite(func(host string, info *storage.SiteInfo) error {
_ = r.store.ForEachSite(func(host string, info *storage.SiteInfo) error {
if filter != nil && !filter(info) {
return nil
}
@@ -336,7 +336,7 @@ func (r *Runner) aggregateWithScores(scores map[string]float64, stats *siteStats
serverTable := buildServerTable(stats.serverCount)
vectors := make(map[string][]float32)
_ = r.db.ForEachSite(func(host string, info *storage.SiteInfo) error {
_ = r.store.ForEachSite(func(host string, info *storage.SiteInfo) error {
score, ok := scores[host]
if !ok || strings.Contains(host, "/") {
return nil