세션 해제 콜백 추가
This commit is contained in:
@ -161,7 +161,12 @@ func newConsumerWithRedis(ctx context.Context, redisUrl string, ttl time.Duratio
|
||||
switch msg.Channel {
|
||||
case deleteChannel:
|
||||
sk := storagekey(msg.Payload)
|
||||
consumer.delete(sk)
|
||||
old := consumer.delete(sk)
|
||||
if old != nil {
|
||||
for _, f := range consumer.onSessionInvalidated {
|
||||
f(old.Account)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -286,3 +291,7 @@ func (c *consumer_redis) Touch(pk string) (Authorization, error) {
|
||||
|
||||
return Authorization{}, nil
|
||||
}
|
||||
|
||||
func (c *consumer_redis) RegisterOnSessionInvalidated(cb func(primitive.ObjectID)) {
|
||||
c.onSessionInvalidated = append(c.onSessionInvalidated, cb)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user