feat: 交易日9:31清空全部缓存,保证开盘后数据全新

- services/cache.py 新增 clear_all() 清空整个 cache 表
- daily_collector.py 新增 cache_cleanup_loop() 后台循环:精确 sleep 到最近一个
  工作日 9:31 清空缓存,跳过周末,出错1分钟重试
- main.py lifespan 启动清理任务,与采集任务一同优雅退出

与既有"非交易时段 TTL 截止到下次开盘前"的惰性过期形成双保险

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Sakurasan
2026-08-11 16:56:56 +08:00
co-authored by Claude
parent 7fe8074e22
commit eb66ab02d0
3 changed files with 65 additions and 6 deletions
+10
View File
@@ -56,3 +56,13 @@ def clean_expired():
conn.commit()
finally:
conn.close()
def clear_all():
"""清空全部缓存(每日开盘后 9:31 调用,保证当日数据全新)"""
conn = get_connection()
try:
conn.execute("DELETE FROM cache")
conn.commit()
finally:
conn.close()