Skip to content

Commit d5ec70a

Browse files
committed
Handle incoming "invalidate" messages from pubsub
1 parent 987bdfc commit d5ec70a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pubsub.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,21 @@ func (c *PubSub) newMessage(reply interface{}) (interface{}, error) {
409409
return &Pong{
410410
Payload: reply[1].(string),
411411
}, nil
412+
case "invalidate":
413+
msg := Message{
414+
Channel: "__redis__:invalidate",
415+
}
416+
keys, ok := reply[1].([]any)
417+
if !ok {
418+
return nil, fmt.Errorf("redis: unsupported pubsub message: %q", kind)
419+
}
420+
out := make([]string, len(keys))
421+
for i, key := range keys {
422+
out[i] = key.(string)
423+
}
424+
msg.PayloadSlice = out
425+
426+
return &msg, nil
412427
default:
413428
return nil, fmt.Errorf("redis: unsupported pubsub message: %q", kind)
414429
}

0 commit comments

Comments
 (0)