1
0
forked from baron/baron-sso

add PROFILE_CACHE_TTL

This commit is contained in:
2026-02-06 12:54:34 +09:00
parent 0e0d8c1ebc
commit 93a11c80a5
2 changed files with 11 additions and 2 deletions

View File

@@ -3807,8 +3807,14 @@ func (h *AuthHandler) resolveCurrentProfile(c *fiber.Ctx) (*domain.UserProfileRe
// 4. Save to Redis Cache (Short TTL)
if h.RedisService != nil && cacheKey != "" {
if data, err := json.Marshal(profile); err == nil {
// TTL: 1 minute to balance consistency and performance
_ = h.RedisService.Set(cacheKey, string(data), 1*time.Minute)
ttlStr := os.Getenv("PROFILE_CACHE_TTL")
ttl := 30 * time.Minute // Default TTL
if ttlStr != "" {
if parsed, err := time.ParseDuration(ttlStr); err == nil {
ttl = parsed
}
}
_ = h.RedisService.Set(cacheKey, string(data), ttl)
}
}