go_dreamfactory/sys/cache/cache.go
2022-06-15 14:09:41 +08:00

33 lines
698 B
Go

package cache
import "go_dreamfactory/lego/sys/redis"
/*
缓存系统的基础结构 包含系统的配置阐述以及 底层操作redis的 redis.ISys 对象
*/
func newSys(options Options) (sys *Cache, err error) {
sys = &Cache{options: options}
err = sys.init()
return
}
type Cache struct {
options Options
redis redis.ISys
}
//初始化 redis 对象
func (this *Cache) init() (err error) {
this.redis, err = redis.NewSys(
redis.SetRedisType(redis.Redis_Cluster),
redis.SetRedis_Cluster_Addr(this.options.Redis_Addr),
redis.SetRedis_Cluster_Password(this.options.Redis_Password))
return
}
//初始化 redis 对象
func (this *Cache) Redis() redis.ISys {
return this.redis
}