打印缓存统计

This commit is contained in:
zhangkun9038@dingtalk.com 2025-08-20 23:55:16 +08:00
parent e02129a717
commit c0b1530b7f

View File

@ -1728,11 +1728,12 @@ class FreqaiPrimer(IStrategy):
self.cleanup_local_cache()
# 打印缓存统计
stats = self.get_cache_stats()
if stats['total_requests'] > 0:
logger.info(f"📊 缓存性能统计: 本地命中率 {stats['local_hit_rate']:.1f}%, "
f"Redis命中率 {stats['redis_hit_rate']:.1f}%, "
f"总命中率 {stats['overall_hit_rate']:.1f}%")
stats = self._local_cache_stats
total_requests = stats['hits'] + stats['misses']
if total_requests > 0:
local_hit_rate = (stats['hits'] / total_requests) * 100
logger.info(f"📊 缓存性能统计: 本地命中率 {local_hit_rate:.1f}%, "
f"计算次数: {stats['computes']}")
def bot_start(self, **kwargs) -> None:
"""
@ -1764,13 +1765,14 @@ class FreqaiPrimer(IStrategy):
self.cleanup_local_cache()
# 打印最终统计
stats = self.get_cache_stats()
if stats['total_requests'] > 0:
logger.info(f"📊 最终缓存统计 - 总请求: {stats['total_requests']}, "
f"本地命中: {stats['local_hits']}, "
f"Redis命中: {stats['redis_hits']}, "
stats = self._local_cache_stats
total_requests = stats['hits'] + stats['misses']
if total_requests > 0:
hit_rate = (stats['hits'] / total_requests) * 100
logger.info(f"📊 最终缓存统计 - 总请求: {total_requests}, "
f"本地命中: {stats['hits']}, "
f"计算次数: {stats['computes']}, "
f"总命中率: {stats['overall_hit_rate']:.1f}%")
f"总命中率: {hit_rate:.1f}%")
# 注意由于使用延迟初始化无需关闭持久化的Redis连接