From 7e7a2baab4c5ccb9dd8dc5104041c9efe718ed9a Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期六, 30 三月 2024 17:28:47 +0800 Subject: [PATCH] 修改缓存更新的数据结构 --- compare/compare.go | 1 + db/person.go | 8 ++++---- cache/cache.go | 10 +++++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/cache/cache.go b/cache/cache.go index 76e8634..aee3708 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -130,14 +130,14 @@ logger.Error(err) return } - if info.Tableid != "" { + if info.AreaId != "" { CacheMap.Lock() defer CacheMap.Unlock() - if _, ok := CacheMap.Area[info.Tableid]; !ok { - CacheMap.Area[info.Tableid] = shardmap.New(uint8(*threadnum)) + if _, ok := CacheMap.Area[info.AreaId]; !ok { + CacheMap.Area[info.AreaId] = shardmap.New(uint8(*threadnum)) } - CacheMap.Area[info.Tableid].Set(info.Id, info) - CacheMap.Area[info.Tableid].Settime() + CacheMap.Area[info.AreaId].Set(info.Id, info) + CacheMap.Area[info.AreaId].Settime() } } diff --git a/compare/compare.go b/compare/compare.go index 8579c57..5b86ce6 100644 --- a/compare/compare.go +++ b/compare/compare.go @@ -63,6 +63,7 @@ targets := val.Walk(DoSdkCompare, args.FaceFeature, baseScore) if len(targets) > 0 { scResult.CompareResult = append(scResult.CompareResult, targets...) + // todo 娣诲姞灏忓尯澶栫殑鍏宠仈鍏崇郴, 涓嬫浼樺厛姣斿 } } diff --git a/db/person.go b/db/person.go index 40240c7..605847b 100644 --- a/db/person.go +++ b/db/person.go @@ -1,7 +1,6 @@ package db import ( - "basic.com/pubsub/protomsg.git" "strconv" ) @@ -68,7 +67,7 @@ return } -func (dbp *DbPersons) GetPersonsCompareCacheById(id string) (info *protomsg.Esinfo, err error) { +func (dbp *DbPersons) GetPersonsCompareCacheById(id string) (info *FeatureCacheBase, err error) { sql := "select id,faceFeature,tableId,enable from dbtablepersons where id = \"" + id + "\"" var p DbPersons err = db.Raw(sql).First(&p).Error @@ -76,9 +75,10 @@ return nil, err } if p.FaceFeature != "" { - info = &protomsg.Esinfo{ + info = &FeatureCacheBase{ Id: p.Id, - Tableid: p.TableId, + TableId: p.TableId, + AreaId: p.AreaID, FaceFeature: p.FaceFeature, Enable: int32(p.Enable), } -- Gitblit v1.8.0