diff --git a/src/models/redis.js b/src/models/redis.js index f02739d2..5036b354 100644 --- a/src/models/redis.js +++ b/src/models/redis.js @@ -407,18 +407,18 @@ class RedisClient { // 🔐 会话管理(用于管理员登录等) async setSession(sessionId, sessionData, ttl = 86400) { - const key = `admin_session:${sessionId}`; + const key = `session:${sessionId}`; await this.client.hset(key, sessionData); await this.client.expire(key, ttl); } async getSession(sessionId) { - const key = `admin_session:${sessionId}`; + const key = `session:${sessionId}`; return await this.client.hgetall(key); } async deleteSession(sessionId) { - const key = `admin_session:${sessionId}`; + const key = `session:${sessionId}`; return await this.client.del(key); } @@ -665,17 +665,17 @@ class RedisClient { // 🔗 会话sticky映射管理 async setSessionAccountMapping(sessionHash, accountId, ttl = 3600) { - const key = `session:${sessionHash}`; + const key = `sticky_session:${sessionHash}`; await this.client.set(key, accountId, 'EX', ttl); } async getSessionAccountMapping(sessionHash) { - const key = `session:${sessionHash}`; + const key = `sticky_session:${sessionHash}`; return await this.client.get(key); } async deleteSessionAccountMapping(sessionHash) { - const key = `session:${sessionHash}`; + const key = `sticky_session:${sessionHash}`; return await this.client.del(key); } @@ -686,6 +686,7 @@ class RedisClient { 'usage:daily:*', 'ratelimit:*', 'session:*', + 'sticky_session:*', 'oauth:*' ]; diff --git a/src/utils/sessionHelper.js b/src/utils/sessionHelper.js index 6f040b82..c4abb430 100644 --- a/src/utils/sessionHelper.js +++ b/src/utils/sessionHelper.js @@ -100,7 +100,7 @@ class SessionHelper { * @returns {string} - Redis键名 */ getSessionRedisKey(sessionHash) { - return `session:${sessionHash}`; + return `sticky_session:${sessionHash}`; } /**