fix: add lock map data structure, fixed bug for 'concurrent map writes'

This commit is contained in:
RockYang
2023-06-16 15:32:11 +08:00
parent 3347b4c990
commit 6f37024e34
10 changed files with 191 additions and 54 deletions

View File

@@ -89,7 +89,7 @@ func (h *ChatHandler) Remove(c *gin.Context) {
}
// 清空会话上下文
delete(h.app.ChatContexts, chatId)
h.app.ChatContexts.Delete(chatId)
resp.SUCCESS(c, types.OkMsg)
}
@@ -144,7 +144,7 @@ func (h *ChatHandler) Clear(c *gin.Context) {
logger.Warnf("Failed to delele chat history for ChatID: %s", chat.ChatId)
}
// 清空会话上下文
delete(h.app.ChatContexts, chat.ChatId)
h.app.ChatContexts.Delete(chat.ChatId)
}
// 删除所有的会话记录
res = h.db.Where("user_id = ?", user.Id).Delete(&model.ChatItem{})