Documentation ¶
Index ¶
Constants ¶
View Source
const ( // DefBasePath 默认路由前缀 DefBasePath = "/RCache/" // DefReplicas 默认虚拟节点倍率 DefReplicas = 50 // DefHTTP 默认前缀 DefHTTP = "http://" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByteView ¶
type ByteView struct {
// contains filtered or unexported fields
}
ByteView 一个只读数据结构,用来表示缓存值
type GetterFunc ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group 分布式缓存组
func (*Group) RegisterPeers ¶
func (g *Group) RegisterPeers(peers PeerPicker)
RegisterPeers 方法,将 实现了 PeerPicker 接口的 HTTPPool 注入到 Group 中。
func (*Group) StartCacheServer ¶
StartCacheServer 开启分布式缓存 addr 当前主机ip及端口,address 所有主机ip及端口
func (*Group) StartServer ¶
StartServer StartAPIServer 启动辅助服务
type HttpPool ¶
type HttpPool struct {
// contains filtered or unexported fields
}
HttpPool 节点间 HTTP 通信的核心数据结构
func NewHTTPPool ¶
func (*HttpPool) PickPeer ¶
func (hp *HttpPool) PickPeer(key string) (PeerGetter, bool)
PickPeer 为 key 选择一个节点
type PeerGetter ¶
PeerGetter 接口对应 HTTP 客户端 PeerGetter,其 Get() 方法用于从对应 group 查找缓存值
type PeerPicker ¶
type PeerPicker interface {
PickPeer(key string) (peer PeerGetter, ok bool)
}
PeerPicker 对应 HttpPool,其 PickPeer() 方法用于根据传入的 key 选择相应节点 PeerGetter。
Click to show internal directories.
Click to hide internal directories.