1 Star 0 Fork 0

mysoft-free/cron-task

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
storage.go 725 Bytes
一键复制 编辑 原始数据 按行查看 历史
JYoung 提交于 2020-06-03 15:34 +08:00 . 增加强制写,增加storage/release方法
package storage
import (
"gitee.com/mysoft-free/cron-task/lib/context"
"sync"
)
//定义存储的接口
type IStorage interface {
Set(key string ,value interface{},force bool)error
Get(key string)(interface{},error)
Del(key string)error
Release(keys ...string)error
}
//获取新的存储引擎
func NewStorage(context *context.Context) IStorage {
stype := context.Config.HttpServer.Storage
switch stype {
case "local":
return &LocalStorage{sMap:sync.Map{}}
case "redis":
s := &RedisStorage{}
redis :=context.Config.Redis //关联原配置redis
s.Init(redis.Addr,redis.Password,redis.DB)
return s
default:
return nil
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/mysoft-free/cron-task.git
git@gitee.com:mysoft-free/cron-task.git
mysoft-free
cron-task
cron-task
80b3c92effd7

搜索帮助