From a2c0678e8d34d1bd5afa26c6a2b34ec97b411777 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期三, 08 五月 2024 14:45:19 +0800
Subject: [PATCH] 新增删除人员缓存的处理

---
 cache/cache.go |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/cache/cache.go b/cache/cache.go
index 76e8634..bfaceb8 100644
--- a/cache/cache.go
+++ b/cache/cache.go
@@ -90,7 +90,7 @@
 					logger.Error(err)
 					return
 				}
-				logger.Debugf("鑾峰彇%d鏉′汉鍛樹俊鎭�", len(dbPersons))
+				logger.Debugf(" eachNum:%d, 鑾峰彇%d鏉′汉鍛樹俊鎭�", queryEachNum, len(dbPersons))
 				CacheMap.Lock()
 
 				areaId := ""
@@ -130,14 +130,23 @@
 		logger.Error(err)
 		return
 	}
-	if info.Tableid != "" {
+	if info != nil && 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()
+	}
+}
+
+func DeleteDbPersonsCacheById(id string) {
+	CacheMap.Lock()
+	defer CacheMap.Unlock()
+
+	for key, _ := range CacheMap.Area {
+		CacheMap.Area[key].Del(id)
 	}
 }
 

--
Gitblit v1.8.0