上传基础缓存组件和db组件的初始化过程
This commit is contained in:
parent
bf91c8c8d2
commit
46cf7e2740
@ -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
|
||||
}
|
||||
|
@ -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
5
sys/cache/cache.go
vendored
@ -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
8
sys/cache/core.go
vendored
@ -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()
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -24,3 +24,6 @@ func (this *DB) init() (err error) {
|
||||
}
|
||||
return
|
||||
}
|
||||
func (this *DB) Mgo() mgo.ISys {
|
||||
return this.mgo
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user