YouTubeRecursosPreçosBlogue
Começar grátis
← Voltar ao blog

Como o cache reduz custos de IA em 60%

30/05/2026

The spam attack problem

A viral video might receive 10,000 identical crypto scam comments. Without caching, each one triggers a separate AI API call.

Two-layer cache

  1. Exact match — PostgreSQL KV lookup, 7-day TTL
  2. Similarity match — pgvector cosine distance < 0.05 returns majority classification

Fallback when AI is slow

If OpenAI latency exceeds 3 seconds, a rule-based classifier takes over automatically. See AI spam detection details.