zhangzengfei
2024-03-30 7e7a2baab4c5ccb9dd8dc5104041c9efe718ed9a
修改缓存更新的数据结构
3个文件已修改
19 ■■■■ 已修改文件
cache/cache.go 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
compare/compare.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
db/person.go 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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()
    }
}
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 添加小区外的关联关系, 下次优先比对
        }
    }
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),
        }