feat: 重构异步模型字段并更新依赖

This commit is contained in:
2026-06-08 18:01:54 +08:00
parent ee6677c1f8
commit e1461cf0f0
12 changed files with 219 additions and 335 deletions

View File

@@ -34,7 +34,6 @@ func saveToRedis(ctx context.Context, session *entity.ComposeSession) error {
if err != nil {
return fmt.Errorf("序列化会话数据失败: %w", err)
}
if err = executeRedisCommands(ctx, key, string(b), maxRounds, expireSeconds); err != nil {
return err
}
@@ -50,18 +49,15 @@ func executeRedisCommands(ctx context.Context, key string, value string, maxRoun
if _, err := g.Redis().Do(ctx, "LTRIM", key, 0, maxRounds-1); err != nil {
return fmt.Errorf("裁剪Redis列表失败: %w", err)
}
if _, err := g.Redis().Do(ctx, "EXPIRE", key, expireSeconds); err != nil {
return fmt.Errorf("设置过期时间失败: %w", err)
}
return nil
}
// getFromRedis 从Redis获取会话历史
func getFromRedis(ctx context.Context, sessionId string) ([]map[string]any, error) {
key := formatRedisKey(sessionId)
result, err := g.Redis().Do(ctx, "LRANGE", key, 0, -1)
if err != nil {
return nil, fmt.Errorf("从Redis获取数据失败: %w", err)