consistenthash

package
v0.0.0-...-1173c81 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash

type Hash func(data []byte) uint32

Hash function ,using dependecy injection, allow sustitute to self define Hash;

type Map

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

Map contains all hashed keys

func New

func New(replicas int, fn Hash) *Map

New Creates a map instance

func (*Map) Add

func (m *Map) Add(keys ...string)

add some keys to hash, allow passing 0 or multiple key

func (*Map) Get

func (m *Map) Get(key string) string

1. calcuate hash of key 2. using binary search to find a vnode -->idx 3. find a node using m.hashmap 4. m

func (*Map) GetKeys

func (m *Map) GetKeys() []int

Jump to

Keyboard shortcuts

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