Documentation ¶
Index ¶
Constants ¶
View Source
const (
ReplicaCount = 20 // 固定大小的虚拟节点数量
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Consistent ¶
type Consistent struct {
// contains filtered or unexported fields
}
Consistent 一致性hash code inspired by github.com/stathat/consistent
func New ¶
func New() *Consistent
func (*Consistent) Add ¶ added in v1.0.4
func (c *Consistent) Add(nodes ...int32)
Add inserts an int32 node in the consistent hash.
func (*Consistent) Clear ¶
func (c *Consistent) Clear()
func (*Consistent) Get ¶ added in v1.0.4
func (c *Consistent) Get(name string) int32
Get returns an element close to where name hashes to in the circle.
func (*Consistent) GetBy ¶ added in v1.0.4
func (c *Consistent) GetBy(key int64) int32
GetBy returns an element close to where name hashes to in the circle.
func (*Consistent) Len ¶ added in v1.0.4
func (c *Consistent) Len() int
func (*Consistent) Members ¶
func (c *Consistent) Members() []int32
func (*Consistent) Remove ¶ added in v1.0.4
func (c *Consistent) Remove(nodes ...int32)
Remove removes an int32 node from the hash.
Click to show internal directories.
Click to hide internal directories.