consistent

package module
v0.0.0-...-020be89 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2016 License: MIT Imports: 3 Imported by: 0

README

Consistent Hash

Consistent hash type for Go.

Description

Hashing items onto a circle of values.

Paraphrasing wikipedia:

Associate each hashed item with one (or more) hash value intervals. Interval boundaries are determined by calculating the hash of each hashed item's identifier.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consistent

type Consistent struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New(fn Hash) *Consistent

func (*Consistent) Add

func (m *Consistent) Add(key string) int

Add a key to the hash.

func (*Consistent) Get

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

Get the item in the hash the provided key is in the range of.

func (*Consistent) Hash

func (m *Consistent) Hash(key string) int

Hash a key.

func (*Consistent) IsEmpty

func (m *Consistent) IsEmpty() bool

Returns true if there are no items available.

func (*Consistent) Next

func (m *Consistent) Next(key string) string

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

func (*Consistent) Range

func (m *Consistent) Range(host string) (int, int)

Get the range of hash keys to the provided item.

func (*Consistent) Remove

func (m *Consistent) Remove(key string)

Remove a key from the hash.

type Hash

type Hash func(data []byte) uint32

Jump to

Keyboard shortcuts

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