解决session在重启后,内存中不存在的问题

This commit is contained in:
heavyrain.lee
2019-05-24 16:33:35 +08:00
parent 3ef973ffc5
commit 675025c0ec
5 changed files with 19 additions and 5 deletions
@@ -282,7 +282,7 @@ public class MemorySessionStore implements ISessionsStore {
@Override
public ErrorCode createNewSession(String username, String clientID, boolean cleanSession) {
public ErrorCode createNewSession(String username, String clientID, boolean cleanSession, boolean createWhenNoExist) {
LOG.debug("createNewSession for client <{}>", clientID);
Session session = sessions.get(clientID);
@@ -296,6 +296,10 @@ public class MemorySessionStore implements ISessionsStore {
session = databaseStore.getSession(username, clientID, clientSession);
if (session == null) {
if (!createWhenNoExist) {
return ErrorCode.ERROR_CODE_NOT_EXIST;
}
session = databaseStore.createSession(username, clientID, clientSession);
}