consistenthash

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChMap

type ChMap struct {
	// contains filtered or unexported fields
}

ChMap consistent hash map

func NewChMap

func NewChMap(replicates int) *ChMap

NewChMap create a ChMap which has replicates of virtual nodes.

func (*ChMap) Add

func (c *ChMap) Add(node KV) error

Add : add the node to the hash ring

func (*ChMap) Find

func (c *ChMap) Find(key string) (KV, bool)

Find finds a nodes to put the string key

func (*ChMap) FindUint32

func (c *ChMap) FindUint32(key uint32) (KV, bool)

FindUint32 finds a nodes to put the uint32 key

func (*ChMap) Remove

func (c *ChMap) Remove(node KV) error

Remove : remove the node and all the virtual nodes from the key

type KV

type KV interface {
	HashKey() string
}

KV is the key value type.

Jump to

Keyboard shortcuts

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