Documentation ¶
Index ¶
- type ByteView
- type Getter
- type GetterFunc
- type Group
- type HTTPPool
- func (p *HTTPPool) GetAll() []PeerGetter
- func (p *HTTPPool) Log(format string, v ...any)
- func (p *HTTPPool) PickPeer(key string) (PeerGetter, bool)
- func (p *HTTPPool) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (p *HTTPPool) Set(peers ...string)
- func (p *HTTPPool) SetETCDRegistry(ctx context.Context, etcdAddrs ...string) error
- type PeerGetter
- type PeerPicker
Constants ¶
This section is empty.
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
func (*Group) SetEmptyWhenError ¶
SetEmptyWhenError 当getter返回error时设置空值,缓解缓存穿透问题 为0表示该机制不生效
func (*Group) SetHotCache ¶
SetHotCache 设置远程节点Hot Key-Value的缓存,避免频繁请求远程节点
type HTTPPool ¶
type HTTPPool struct {
// contains filtered or unexported fields
}
HTTPPool 实现了伙伴节点
func (*HTTPPool) PickPeer ¶
func (p *HTTPPool) PickPeer(key string) (PeerGetter, bool)
PickPeer 根据键获取对应的远程节点客户端
type PeerGetter ¶
type PeerGetter interface { Get(in *pb.Request, out *pb.Response) error Remove(in *pb.Request) error }
PeerGetter 远程客户端,根据group和key获取缓存
type PeerPicker ¶
type PeerPicker interface { PickPeer(key string) (PeerGetter, bool) GetAll() []PeerGetter }
PeerPicker 用于获取远程节点的请求客户端
Click to show internal directories.
Click to hide internal directories.