48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
||
"""
|
||
清除缓存脚本
|
||
用于清除旧的K线数据缓存,确保使用新的180天数据
|
||
"""
|
||
import sys
|
||
from pathlib import Path
|
||
|
||
# 添加项目路径
|
||
sys.path.insert(0, str(Path(__file__).parent / 'backend'))
|
||
|
||
from app.services.cache_service import cache_service
|
||
|
||
def main():
|
||
print("=" * 60)
|
||
print("清除K线数据缓存")
|
||
print("=" * 60)
|
||
|
||
try:
|
||
# 方案1:清除K线相关缓存
|
||
kline_count = cache_service.clear_pattern("kline:")
|
||
print(f"\n✓ 清除K线缓存: {kline_count} 条")
|
||
|
||
# 方案2:清除所有缓存(可选)
|
||
print("\n是否清除所有缓存?(y/n): ", end="")
|
||
choice = input().strip().lower()
|
||
|
||
if choice == 'y':
|
||
total_count = cache_service.clear_all()
|
||
print(f"✓ 清除所有缓存: {total_count} 条")
|
||
|
||
print("\n说明:")
|
||
print("- 已清除K线数据缓存")
|
||
print("- 下次查询时将使用新的180天数据范围")
|
||
print("- 技术指标将基于更完整的历史数据计算")
|
||
print("\n建议:重启应用以确保生效")
|
||
print(" pm2 restart stock-agent")
|
||
|
||
except Exception as e:
|
||
print(f"\n✗ 清除缓存失败: {e}")
|
||
import traceback
|
||
print(traceback.format_exc())
|
||
|
||
print("\n" + "=" * 60)
|
||
|
||
if __name__ == "__main__":
|
||
main()
|