cache

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache(size int) *Cache

func (*Cache) Get

func (c *Cache) Get(key string) interface{}

func (*Cache) Set

func (c *Cache) Set(key string, value interface{})

type Hash

type Hash func(data []byte) uint32

Hash 函数用来转换字符串为2的32次方-1中的一个hash位点

type Ring

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

Ring 一致性hash环用来存储节点

func NewRing

func NewRing() *Ring

func (*Ring) Add

func (r *Ring) Add(node string)

Add 添加节点

func (*Ring) Get

func (r *Ring) Get(key string) (node string)

Get 根据key获取数据所在的节点

func (*Ring) Remove

func (r *Ring) Remove(node string)

Remove 删除节点

Jump to

Keyboard shortcuts

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