consistent

package
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2024 License: BSD-3-Clause Imports: 1 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL