Documentation
¶
Overview ¶
并发控制
Index ¶
- func CloneBytes(b []byte) []byte
- type ByteView
- type CacheClient
- type CacheServer
- type Getter
- type GetterFunc
- type Group
- func (g *Group) Get(key string) (ByteView, error)
- func (g *Group) GetFromPeer(peer PeerGetter, key string) (ByteView, error)
- func (g *Group) GetLocally(key string) (ByteView, error)
- func (g *Group) Load(key string) (ByteView, error)
- func (g *Group) PopulateCache(key string, value ByteView)
- func (g *Group) RegisterPeers(peers PeerPicker)
- type PeerGetter
- type PeerPicker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloneBytes ¶
Types ¶
type ByteView ¶
type ByteView struct {
// contains filtered or unexported fields
}
只读数据结构,表示缓存值
type CacheClient ¶
type CacheClient struct {
BaseURL string //BaseURL example : http://localhost:8888
}
rpc客户端
type CacheServer ¶
type CacheServer struct { cachepb.UnimplementedGroupCacheServer Self string //Self example : http://localhost:8888 Getters map[string]*CacheClient // contains filtered or unexported fields }
rpc服务器
func (*CacheServer) PickPeer ¶
func (CS *CacheServer) PickPeer(key string) (PeerGetter, bool)
利用一致性哈希选择远端节点
type GetterFunc ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
缓存组,一个缓存组可以有多个分布式节点 同名缓存组共享逻辑地址,如果两个节点在同名缓存组内,它们属于同一个子系统
func (*Group) GetFromPeer ¶
func (g *Group) GetFromPeer(peer PeerGetter, key string) (ByteView, error)
从远端节点获取缓存
func (*Group) GetLocally ¶
使用回调函数从本地数据源获取key对应的value值并加载到缓存
func (*Group) PopulateCache ¶
将key-value加载到缓存
type PeerGetter ¶
type PeerPicker ¶
type PeerPicker interface {
PickPeer(key string) (peer PeerGetter, ok bool)
}
Click to show internal directories.
Click to hide internal directories.