Back to godoc.org
github.com/go-redis/redis / internal / consistenthash

Package consistenthash

v0.0.0-...-16ab0f2
Latest Go to latest

The latest major version is v8.

Published: Aug 7, 2020 | License: BSD-2-Clause | Module: github.com/go-redis/redis

Overview

Package consistenthash provides an implementation of a ring hash.

Index

type Hash

type Hash func(data []byte) uint32

type Map

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

func New

func New(replicas int, fn Hash) *Map

func (*Map) Add

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

Adds some keys to the hash.

func (*Map) Get

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

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

func (*Map) IsEmpty

func (m *Map) IsEmpty() bool

Returns true if there are no items available.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier