Browse Source

feat:批量清缓存

wangchuanjin 1 năm trước cách đây
mục cha
commit
169c5dca81
1 tập tin đã thay đổi với 7 bổ sung5 xóa
  1. 7 5
      entity/user.go

+ 7 - 5
entity/user.go

@@ -274,12 +274,14 @@ func ClearUserPowerFunc(positionId, appId string) bool {
 	if positionId == "" {
 		return false
 	}
-	for _, v := range []string{"PC", "APP", "WX"} {
-		redis.Del(RedisCode, fmt.Sprintf(RedisMenuKey, appId, v, ConfigJson.MenuCacheKey, positionId))
+	for _, v := range strings.Split(positionId, ",") {
+		for _, v := range []string{"PC", "APP", "WX"} {
+			//用户菜单缓存
+			redis.Del(RedisCode, fmt.Sprintf(RedisMenuKey, appId, v, ConfigJson.MenuCacheKey, v))
+		}
+		//用户权限缓存
+		redis.Del(RedisCode, fmt.Sprintf(UserPowerRedisKey, appId, time.Now().Day(), v))
 	}
-	//用户权限缓存
-	redis.Del(RedisCode, fmt.Sprintf(UserPowerRedisKey, appId, time.Now().Day(), positionId))
-	//用户菜单缓存
 	return true
 }