hash

package
v3.7.23 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(data []byte) uint32

Hash 返回数据的哈希值

Types

type ConsistentHash

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

ConsistentHash is a ring hash implementation.

func NewConsistentHash

func NewConsistentHash() *ConsistentHash

NewConsistentHash returns a ConsistentHash.

func NewCustomConsistentHash

func NewCustomConsistentHash(replicas int, fn Func) *ConsistentHash

NewCustomConsistentHash returns a ConsistentHash with given replicas and hash func.

func (*ConsistentHash) Add

func (h *ConsistentHash) Add(keys ...string) *ConsistentHash

func (*ConsistentHash) Get

func (h *ConsistentHash) Get(key string) string

Get the closest item in the hash to the provided key.

func (*ConsistentHash) IsEmpty

func (h *ConsistentHash) IsEmpty() bool

IsEmpty Returns true if there are no items available.

type Func

type Func func(data []byte) uint32

Func defines the hash method.

Jump to

Keyboard shortcuts

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