Skip to content

Commit

Permalink
bugfix: Fix ksn bug (#785)
Browse files Browse the repository at this point in the history
  • Loading branch information
blight19 authored Apr 1, 2024
1 parent 21781b9 commit ee110e4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/reader/scan_standalone_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ func (r *scanStandaloneReader) subscript() {
}
c := client.NewRedisClient(r.ctx, r.opts.Address, r.opts.Username, r.opts.Password, r.opts.Tls)
c.Send("psubscribe", "__keyevent@*__:*")

// filter dbs
dbIDmap := make(map[int]struct{})
for _, db := range r.dbs {
dbIDmap[db] = struct{}{}
}
go func() {
_, err := c.Receive()
if err != nil {
Expand All @@ -114,7 +118,10 @@ func (r *scanStandaloneReader) subscript() {
if err != nil {
log.Panicf(err.Error())
}
r.keyQueue.Put(dbKey{db: dbIdInt, key: key})
// if the db is not in the dbs, ignore it
if _, ok := dbIDmap[dbIdInt]; ok {
r.keyQueue.Put(dbKey{db: dbIdInt, key: key})
}
}
}
}()
Expand Down

0 comments on commit ee110e4

Please sign in to comment.