feat:完善项目

This commit is contained in:
henry
2021-09-28 11:47:19 +08:00
commit da7b3130fe
167 changed files with 456676 additions and 0 deletions

44
serve/cache/init.go vendored Normal file
View File

@ -0,0 +1,44 @@
package cache
import (
"SciencesServer/config"
"SciencesServer/serve/cache/logic"
"fmt"
)
var (
Cache logic.ICache
engines = map[string]func() logic.ICache{
"memory": memory, "redis": redis,
}
)
func memory() logic.ICache {
return logic.NewMemory()
}
func redis() logic.ICache {
return logic.NewRedis(&logic.RedisOption{
Addr: config.SettingInfo.Cache.Redis.Addr,
Password: config.SettingInfo.Cache.Redis.Password,
DB: config.SettingInfo.Cache.Redis.DB,
MinIdleConns: config.SettingInfo.Cache.Redis.MaxIdle,
IdleTimeout: config.SettingInfo.Cache.Redis.IdleTimeout,
})
}
func Init() {
handle, has := engines[config.SettingInfo.Cache.Type]
if !has {
panic(fmt.Sprintf("Unknown Cache Engine Mode%s", config.SettingInfo.Cache.Type))
}
Cache = handle()
err := Cache.Run()
if err != nil {
panic("Cache Run Error" + err.Error())
}
}