上传基础缓存组件和db组件的初始化过程

This commit is contained in:
liwei1dao 2022-06-13 18:00:18 +08:00
parent bf91c8c8d2
commit 46cf7e2740
6 changed files with 27 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import (
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/redis"
"go_dreamfactory/sys/cache"
)
/*
@ -22,5 +23,6 @@ func (this *MComp_CacheComp) Init(service core.IService, module core.IModule, co
this.ModuleCompBase.Init(service, module, comp, options)
this.S = service.(base.IRPCXService)
this.M = module
this.Redis = cache.Redis()
return
}

View File

@ -5,6 +5,7 @@ import (
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/sys/db"
)
/*
@ -22,5 +23,6 @@ func (this *MComp_DBComp) Init(service core.IService, module core.IModule, comp
this.ModuleCompBase.Init(service, module, comp, options)
this.S = service.(base.IRPCXService)
this.M = module
this.DB = db.Mgo()
return
}

5
sys/cache/cache.go vendored
View File

@ -25,3 +25,8 @@ func (this *Cache) init() (err error) {
redis.SetRedis_Cluster_Password(this.options.Redis_Password))
return
}
//初始化 redis 对象
func (this *Cache) Redis() redis.ISys {
return this.redis
}

8
sys/cache/core.go vendored
View File

@ -1,11 +1,14 @@
package cache
import "go_dreamfactory/lego/sys/redis"
/*
redis 缓存数据管理系统
*/
type (
ISys interface {
Redis() redis.ISys
IUser //户模块的相关缓存接口
IFriend //好友相关的缓存接口
}
@ -35,3 +38,8 @@ func NewSys(option ...Option) (sys ISys, err error) {
Defsys, err = newSys(options)
return
}
//系统实例化接口 每个系统默认都会提供全局以及实例化的接口
func Redis() redis.ISys {
return Defsys.Redis()
}

View File

@ -1,7 +1,10 @@
package db
import "go_dreamfactory/lego/sys/mgo"
type (
ISys interface {
Mgo() mgo.ISys
IUser
IMail
IFriend
@ -27,3 +30,7 @@ func NewSys(option ...Option) (sys ISys, err error) {
Defsys, err = newSys(options)
return
}
func Mgo() mgo.ISys {
return Defsys.Mgo()
}

View File

@ -24,3 +24,6 @@ func (this *DB) init() (err error) {
}
return
}
func (this *DB) Mgo() mgo.ISys {
return this.mgo
}