From aaaea09c0ec71518310a753d120ec2c26f7f4038 Mon Sep 17 00:00:00 2001 From: panlei <2799247126@qq.com> Date: 星期四, 22 八月 2019 15:50:30 +0800 Subject: [PATCH] read soname from register --- cache/cache.go | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/cache/cache.go b/cache/cache.go index a50f676..4827c70 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -18,6 +18,7 @@ PREFIX_RULE = "RULE_" SERVER_KEY = "SERVERINFO" PREFIX_SDK = "SDK_" + PREFIX_SO = "SO" ) var cMap *shardmap.ShardMap @@ -53,6 +54,8 @@ initServerInfo()//鍒濆鍖栨湇鍔″櫒閰嶇疆淇℃伅 initSdks() //鍒濆鍖杝dk鍒楄〃淇℃伅 + + initSoData() initChan <- true } @@ -202,4 +205,21 @@ } else { return sdk,errors.New("sdk not found") } +} + +func initSoData() { + var api dbapi.SoApi + soinfos := api.FindAll() + for _,soinfo :=range soinfos { + cMap.Set(PREFIX_SO+soinfo.SdkId,soinfo) + } +} + +func GetSoInfoById(sdkId string) (sdk protomsg.SoInfo,err error){ + obj,b :=cMap.Get(PREFIX_SO + sdkId) + if b { + return obj.(protomsg.SoInfo),nil + } else { + return sdk,errors.New("sdk not found") + } } \ No newline at end of file -- Gitblit v1.8.0