consistenthash

package
v0.8.9 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: MIT, Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package consistenthash provides an implementation of a ring hash.

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

type Map

type Map[T any] struct {
	// contains filtered or unexported fields
}

func New

func New[T any](replicas int, fn Hash) *Map[T]

func (*Map[T]) Add

func (m *Map[T]) Add(key string, v T)

Add adds some keys to the hash.

func (*Map[T]) Get

func (m *Map[T]) Get(key string) T

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

func (*Map[T]) IsEmpty

func (m *Map[T]) IsEmpty() bool

IsEmpty returns true if there are no items available.

Jump to

Keyboard shortcuts

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