Skip to content

Commit

Permalink
fix: allow ":" in the custom rueidislock.LockerOption.KeyPrefix
Browse files Browse the repository at this point in the history
Signed-off-by: Rueian <[email protected]>
  • Loading branch information
rueian committed Aug 8, 2024
1 parent e1c75ba commit 44224d4
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions rueidislock/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,21 +265,23 @@ func (m *locker) onInvalidations(messages []rueidis.RedisMessage) {
}
for _, msg := range messages {
k, _ := msg.ToString()
if ks := strings.SplitN(k, ":", 3); len(ks) == 3 {
m.mu.RLock()
g, ok := m.gates[ks[2]]
if ok {
n, _ := strconv.Atoi(ks[1])
select {
case g.csc[n] <- struct{}{}:
default:
}
select {
case g.ch <- struct{}{}:
default:
if strings.HasPrefix(k, m.prefix) {
if ks := strings.SplitN(k[len(m.prefix)+1:], ":", 2); len(ks) == 2 {
m.mu.RLock()
g, ok := m.gates[ks[1]]
if ok {
n, _ := strconv.Atoi(ks[0])
select {
case g.csc[n] <- struct{}{}:
default:
}
select {
case g.ch <- struct{}{}:
default:
}
}
m.mu.RUnlock()
}
m.mu.RUnlock()
}
}
}
Expand Down

0 comments on commit 44224d4

Please sign in to comment.