You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

Tasks: Analysis Storage Refactor

1. StorageManager 扩展

  • 1.1 在 StorageManager 中新增 cache_get() 通用缓存读取方法
  • 1.2 在 StorageManager 中新增 cache_set() 通用缓存写入方法
  • 1.3 在 StorageManager 中新增 cache_delete() 通用缓存删除方法

2. 数据迁移

  • 2.1 创建 app/analysis_migration.py,实现 SQLite → MySQL 迁移逻辑
  • 2.2 在 app/main.pylifespan 中调用迁移函数,启动时自动迁移
  • 2.3 迁移幂等性:检测 MySQL 表是否已有数据,有则跳过

3. 降级逻辑集成

  • 3.1 修改 app/analysis_db.pyget_analysis_db() 根据 MySQL 可用性返回 Session
  • 3.2 实现 MySQL 不可用时降级到 SQLite 的逻辑
  • 3.3 保留 Redis 缓存能力(通过 StorageManager 通用缓存方法)

4. 表结构初始化

  • 4.1 在 app/main.pylifespan 中创建 analysis 表MySQL
  • 4.2 验证 14 张表在 MySQL 中正确创建

5. 测试与验证

  • 5.1 验证 Redis 缓存命中场景
  • 5.2 验证 Redis 缓存未命中回源 MySQL 场景
  • 5.3 验证 MySQL 不可用降级到 SQLite 场景
  • 5.4 验证数据迁移完整性
  • 5.5 验证现有测试套件全部通过101 passed, 2 xfailed