From 3683aae9afcd073eafad4491e54c2eaf9060e997 Mon Sep 17 00:00:00 2001 From: Cold <16419454+cold502@user.noreply.gitee.com> Date: Sat, 20 Dec 2025 15:04:13 +0800 Subject: [PATCH] =?UTF-8?q?=20session=E7=BC=93=E5=AD=98=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=88tenantId+userId=E9=9A=94=E7=A6=BB=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- redis/redis.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/redis/redis.go b/redis/redis.go index 8209d79..1ebfe1c 100644 --- a/redis/redis.go +++ b/redis/redis.go @@ -425,17 +425,17 @@ func GetRateLimit(ctx context.Context, key string) (count int64, err error) { return } -// SetSessionCache 缓存 RAGFlow Session ID(租户+用户+方向隔离) -func SetSessionCache(ctx context.Context, tenantId, userId, chatId, sessionId string) error { - key := SessionLastActiveKeyPrefix + tenantId + ":" + userId + ":" + chatId + ":session_id" +// SetSessionCache 缓存 RAGFlow Session ID(租户+用户隔离) +func SetSessionCache(ctx context.Context, tenantId, userId, sessionId string) error { + key := SessionLastActiveKeyPrefix + tenantId + ":" + userId + ":session_id" // SETEX key 7200 value (7200秒 = 2小时,与last_active保持一致) _, err := redisClient.Do(ctx, "SETEX", key, 7200, sessionId) return err } -// GetSessionCache 获取缓存的 RAGFlow Session ID(租户+用户+方向隔离) -func GetSessionCache(ctx context.Context, tenantId, userId, chatId string) (string, error) { - key := SessionLastActiveKeyPrefix + tenantId + ":" + userId + ":" + chatId + ":session_id" +// GetSessionCache 获取缓存的 RAGFlow Session ID(租户+用户隔离) +func GetSessionCache(ctx context.Context, tenantId, userId string) (string, error) { + key := SessionLastActiveKeyPrefix + tenantId + ":" + userId + ":session_id" result, err := redisClient.Get(ctx, key) if err != nil { return "", err @@ -448,9 +448,9 @@ func GetSessionCache(ctx context.Context, tenantId, userId, chatId string) (stri return result.String(), nil } -// DelSessionCache 删除缓存的 RAGFlow Session ID(归档时调用,租户+用户+方向隔离) -func DelSessionCache(ctx context.Context, tenantId, userId, chatId string) error { - key := SessionLastActiveKeyPrefix + tenantId + ":" + userId + ":" + chatId + ":session_id" +// DelSessionCache 删除缓存的 RAGFlow Session ID(归档时调用,租户+用户隔离) +func DelSessionCache(ctx context.Context, tenantId, userId string) error { + key := SessionLastActiveKeyPrefix + tenantId + ":" + userId + ":session_id" _, err := redisClient.Del(ctx, key) return err }