예제 #1
0
// bucket return a channelBucket use murmurhash3.
func (this *ChannelManagerStruct) bucket(key string) *ChannelBucket {
	h := hash.NewMurmur3C()
	h.Write([]byte(key))
	idx := uint(h.Sum32()) & uint(Conf.ChannelBucket-1)
	log.Debug("user_key:\"%s\" hit channel bucket index:%d", key, idx)
	return this.buckets[idx]
}
예제 #2
0
// bucketIdx return a channelBucket index.
func (this *ChannelManagerStruct) BucketIdx(key *string) uint {
	h := hash.NewMurmur3C()
	h.Write([]byte(*key))
	return uint(h.Sum32()) & uint(Conf.ChannelBucket-1)
}