Skip to content

Commit 1c3b575

Browse files
committed
fix:修复缓存未更新问题
1 parent 697b006 commit 1c3b575

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/main/java/com/xiaozhi/communication/common/SessionManager.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,18 @@ public ListenMode getMode(String sessionId) {
373373
return ListenMode.Auto;
374374
}
375375

376+
/**
377+
* 清空缓存记忆
378+
*
379+
* @param sessionId
380+
*/
381+
public voic setChatMemory(String sessionId, chatMemory memory) {
382+
ChatSession chatSession = sessions.get(sessionId);
383+
if (chatSession != null) {
384+
chatSession.setChatMemory(memory);
385+
}
386+
}
387+
376388
/**
377389
* 设置流式识别状态
378390
*

src/main/java/com/xiaozhi/service/impl/SysDeviceServiceImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ public SysDevice update(SysDevice device) {
225225
@Override
226226
@Transactional(transactionManager = "transactionManager")
227227
public int updateNoRefreshCache(SysDevice device) {
228+
ChatSession session = sessionManager.getSessionByDeviceId(device.getDeviceId());
228229
if (!ObjectUtils.isEmpty(device.getRoleId())) {
229230
SysRole role = roleMapper.selectRoleById(device.getRoleId());
230231
if (role != null) {
@@ -238,6 +239,7 @@ public int updateNoRefreshCache(SysDevice device) {
238239
message.setDeviceId(device.getDeviceId());
239240
// 清空设备聊天记录
240241
messageMapper.delete(message);
242+
session.setChatMemory(sesseion.getId(), null);
241243
}
242244
}
243245
}

0 commit comments

Comments
 (0)