diff --git a/internal/task/polling_card_cache.go b/internal/task/polling_card_cache.go index 0017163..08e1dc5 100644 --- a/internal/task/polling_card_cache.go +++ b/internal/task/polling_card_cache.go @@ -25,7 +25,10 @@ func (b *PollingBase) getCardWithCache(ctx context.Context, cardID uint) (*model return nil, err } - go writeCardToCache(b, key, card) + // 同步写缓存,避免与后续 updateCardCache 产生竞态: + // 若异步协程在 updateCardCache 之后才执行,会将 last_gateway_reading_mb + // 覆盖回 DB 旧值(0),导致下次轮询增量重复计全量。 + writeCardToCache(b, key, card) return card, nil }