Ai
1 Star 0 Fork 0

ABDM/Golang实现分布式缓存

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
peer.go 853 Bytes
一键复制 编辑 原始数据 按行查看 历史
ABDM357 提交于 2021-01-28 22:59 +08:00 . modify001addgolang
package Gache
/*
Q:为什么要实现这两个接口
A:试想,有N个节点,多线程取值,此时是不是每个远程节点都需要
分配一个获取方法(Getter),PeerPicker接口是根据key返回
相应的Getter,而PeerGetter接口则是提供了自定义接口
本文以http为例,peerGetter就是httpGetter,如果用的不是
http协议,更甚至是用数据库等,用户就可以自定义Getter了
*/
/*
PeerPicker根据传入的对应的key
选择相应节点的PeerGetter
*/
type PeerPicker interface {
PickPeer(key string)(peer PeerGetter,ok bool)
}
/*
PeerGetter对于Http客户端,通过它得Get函数,
从group找到对于的缓存值
所以写完PeerGetter抽象接口后需要去http.go
中实现PeerGetter接口
*/
type PeerGetter interface {
Get(group string,key string)([]byte,error)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/abdm/Golang_practice.git
git@gitee.com:abdm/Golang_practice.git
abdm
Golang_practice
Golang实现分布式缓存
master

搜索帮助