forked from baron/baron-sso
add PROFILE_CACHE_TTL
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user