hashkit

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HashMethodFnv1a = "fnv1a_64"
)

constants defines

Variables

This section is empty.

Functions

func Crc16 added in v1.4.0

func Crc16(key []byte) (crc uint16)

Crc16 caculate key crc to divide slot of redis

func New64a

func New64a() hash.Hash64

New64a new fnv1a64 same as twemproxy.

Types

type HashRing

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

HashRing ketama hash ring.

func Ketama

func Ketama() (h *HashRing)

Ketama new a hash ring with ketama consistency. Default hash: fnv1a64

func NewRing

func NewRing(des, method string) *HashRing

NewRing will create new and need init method.

func (*HashRing) AddNode

func (h *HashRing) AddNode(node string, spot int)

AddNode a new node to the hash ring. n: name of the server s: multiplier for default number of ticks (useful when one cache node has more resources, like RAM, than another)

func (*HashRing) DelNode

func (h *HashRing) DelNode(n string)

DelNode delete a node from the hash ring. n: name of the server s: multiplier for default number of ticks (useful when one cache node has more resources, like RAM, than another)

func (*HashRing) GetNode

func (h *HashRing) GetNode(key []byte) (string, bool)

GetNode returns result node by given key.

func (*HashRing) Init

func (h *HashRing) Init(nodes []string, spots []int)

Init init hash ring with nodes.

Jump to

Keyboard shortcuts

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