13 Star 89 Fork 13

kelvins-io/g2cache

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
interface.go 1.32 KB
一键复制 编辑 原始数据 按行查看 历史
cristiane 提交于 2021-06-25 09:22 +08:00 . !3发布订阅fix
package g2cache
// Local memory cache,Local memory cache with high access speed
type LocalCache interface {
Get(key string, obj interface{}) (*Entry, bool, error) // obj represents the internal structure of the real object
Set(key string, e *Entry) error // local storage should set Entry.Obsolete
Del(key string) error
ThreadSafe() // Need to ensure thread safety
Close()
}
// External cache has faster access speed, such as Redis
type OutCache interface {
Get(key string, obj interface{}) (*Entry, bool, error) // obj represents the internal structure of the real object
Set(key string, e *Entry) error // out storage should set Entry.Expiration
Del(key string) error
ThreadSafe() // Need to ensure thread safety
Close()
}
// only out storage pub sub
type PubSub interface {
Subscribe(data chan<- *ChannelMeta) error
Publish(gid, key string, action int8, data *Entry) error
}
// Shouldn't throw a panic, please return an error
type LoadDataSourceFunc func() (interface{}, error)
// Entry expire is UnixNano
const (
SetPublishType int8 = iota
DelPublishType
)
type ChannelMeta struct {
Key string `json:"key"` // cache key
Gid string `json:"gid"` // Used to identify working groups
Action int8 `json:"action"` // SetPublishType,DelPublishType
Data *Entry `json:"data"`
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/kelvins-io/g2cache.git
git@gitee.com:kelvins-io/g2cache.git
kelvins-io
g2cache
g2cache
release

搜索帮助