registry.go
1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package configs
import (
"apigame/common/svmysql"
"apigame/common/svredis"
"fmt"
)
// GetApiGameConfig 获取 api游戏配置
func GetApiGameConfig(gameId string) (conf *ApiGameConfig, err error) {
conf = new(ApiGameConfig)
has := svredis.LoadData(gameId, conf)
if has {
fmt.Println("dwjw GetApiGameConfig use cache")
return
}
has, err = svmysql.First(conf, gameId)
if err != nil {
return
}
if !has {
return
}
fmt.Println("dwjw GetApiGameConfig save cache")
svredis.SaveData(gameId, conf)
return
}
// GetCardActivityConfig 获取 卡牌活动配置
func GetCardActivityConfig(gameId string) (conf *CardActivityConfig, has bool) {
var err error
conf = new(CardActivityConfig)
has = svredis.LoadData(gameId, conf)
if has {
fmt.Println("dwjw GetCardActivityConfig use cache")
return
}
confRaw := new(CardActivityConfigRaw)
has, err = svmysql.First(confRaw, gameId)
if err != nil {
return
}
if !has {
return
}
conf.Decode(gameId, confRaw)
fmt.Println("dwjw GetCardActivityConfig save cache")
svredis.SaveData(gameId, conf)
return
}