Documentation ¶
Overview ¶
Package hashring 在理想情况下,每个物理节点受影响的数据量 为其节点缓存数据最的1/4 (X/(N+X))N为原 有物理节点数,X为新加入物理节点数), 也就是集群中已经被缓存的数据有75%可以被继续命中, 和未使用虚拟节点的一致性Hash算法结果相同, 只是解决的负载均衡的问题。 @author: xwc1125 @date: 2021/5/27
Index ¶
- Constants
- type HashRing
- func (h *HashRing) AddNode(nodeKey uint64, weight uint64)
- func (h *HashRing) AddNodes(nodeWeight map[uint64]uint64)
- func (h *HashRing) GetNode(s string) (uint64, error)
- func (h *HashRing) GetWeight() map[uint64]uint64
- func (h *HashRing) RemoveNode(nodeKey uint64)
- func (h *HashRing) UpdateNode(nodeKey uint64, weight uint64)
Constants ¶
View Source
const (
// DefaultVirtualSpots default virtual spots
DefaultVirtualSpots = 400
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HashRing ¶
type HashRing struct {
// contains filtered or unexported fields
}
HashRing store nodes and weights
func NewHashRing ¶
NewHashRing create a hash ring with virtual spots
func (*HashRing) UpdateNode ¶
UpdateNode update node with weight
Click to show internal directories.
Click to hide internal directories.