Files
redis-go/pubsub/hub.go
2021-05-13 08:56:07 +08:00

23 lines
396 B
Go

package pubsub
import (
"github.com/hdt3213/godis/datastruct/dict"
"github.com/hdt3213/godis/datastruct/lock"
)
// Hub stores all subscribe relations
type Hub struct {
// channel -> list(*Client)
subs dict.Dict
// lock channel
subsLocker *lock.Locks
}
// MakeHub creates new hub
func MakeHub() *Hub {
return &Hub{
subs: dict.MakeConcurrent(4),
subsLocker: lock.Make(16),
}
}