1 Star 1 Fork 1

lorock / go-dingtalk-sdk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
cache.go 836 Bytes
一键复制 编辑 原始数据 按行查看 历史
lorock 提交于 2020-11-15 22:27 . 初始化仓库
package cache
import (
"fmt"
"time"
)
//Cache interface
type Cache interface {
Get(key string) interface{}
Set(key string, val interface{}, timeout time.Duration) error
Delete(key string) error
IsExist(key string) bool
Init(cfg interface{}) error
}
var adapters = make(map[string]Cache)
func Register(name string, adapter Cache) {
if adapter == nil {
panic("cache: Register adapter is nil")
}
if _, ok := adapters[name]; ok {
panic("cache: Register called twice for adapter " + name)
}
adapters[name] = adapter
}
func NewCache(adapterName string, config interface{}) (adapter Cache, err error) {
adapter, ok := adapters[adapterName]
if !ok {
err = fmt.Errorf("cache: unknown adapter name %q (forgot to import?)", adapterName)
return
}
err = adapter.Init(config)
if err != nil {
adapter = nil
}
return
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/lorock/go-dingtalk-sdk.git
git@gitee.com:lorock/go-dingtalk-sdk.git
lorock
go-dingtalk-sdk
go-dingtalk-sdk
v1.0.6

搜索帮助

344bd9b3 5694891 D2dac590 5694891