feat: 优化粘性会话TTL管理策略

- 将默认TTL从1小时延长至15天,更适合长期项目开发
- 实现智能续期机制:剩余时间<14天时自动续期到15天
- 添加配置化支持:通过环境变量STICKY_SESSION_TTL_DAYS和STICKY_SESSION_RENEWAL_THRESHOLD_DAYS调整TTL策略
- 集成到所有调度器:Claude、OpenAI、Gemini的普通会话和分组会话
- 提升用户体验:活跃项目会话持续有效,停用项目自动清理
- 性能优化:智能判断减少不必要的Redis EXPIRE操作

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Edric Li
2025-09-08 00:43:33 +08:00
parent 9fa7602947
commit 9cbf3195e0
6 changed files with 74 additions and 2 deletions

View File

@@ -61,6 +61,8 @@ class UnifiedGeminiScheduler {
mappedAccount.accountType
)
if (isAvailable) {
// 🚀 智能会话续期剩余时间少于14天时自动续期到15天
await redis.extendSessionAccountMappingTTL(sessionHash)
logger.info(
`🎯 Using sticky session account: ${mappedAccount.accountId} (${mappedAccount.accountType}) for session ${sessionHash}`
)
@@ -382,6 +384,8 @@ class UnifiedGeminiScheduler {
mappedAccount.accountType
)
if (isAvailable) {
// 🚀 智能会话续期剩余时间少于14天时自动续期到15天
await redis.extendSessionAccountMappingTTL(sessionHash)
logger.info(
`🎯 Using sticky session account from group: ${mappedAccount.accountId} (${mappedAccount.accountType}) for session ${sessionHash}`
)