实现缓存策略的部分功能

This commit is contained in:
刘祥超
2020-10-04 14:27:14 +08:00
parent 9c6efad81f
commit 97f9bb27e7
13 changed files with 762 additions and 197 deletions

View File

@@ -8,12 +8,15 @@ import (
var sharedAPIConfig *APIConfig = nil
// API节点配置
type APIConfig struct {
RPC struct {
Listen string `yaml:"listen"`
} `yaml:"rpc"`
NodeId string `yaml:"nodeId" json:"nodeId"`
Secret string `yaml:"secret" json:"secret"`
numberId int64 // 数字ID
}
// 获取共享配置
func SharedAPIConfig() (*APIConfig, error) {
sharedLocker.Lock()
defer sharedLocker.Unlock()
@@ -36,3 +39,13 @@ func SharedAPIConfig() (*APIConfig, error) {
sharedAPIConfig = config
return config, nil
}
// 设置数字ID
func (this *APIConfig) SetNumberId(numberId int64) {
this.numberId = numberId
}
// 获取数字ID
func (this *APIConfig) NumberId() int64 {
return this.numberId
}