Redis QA Answer Caching (Exact-match, Question Hash Keying)

  • Why caching helps
    • User behavior drives a high repeat rate: on the same document, users often ask repeated or very similar questions—by clicking the same button multiple times, refreshing, slightly rephrasing the question, or even having multiple users ask the exact same thing.
  • How to solve with Redis caching
    • implemented a Redis-based exact-match QA cache
    • by normalizing user questions,
    • hashing them with SHA-256,
    • and using qa:{docId}:{questionHash} as the cache key to serve repeated answers quickly and reduce repeated LLM calls.
  • PostgreSQL is the source of truth. Redis is a performance layer used for caching and ranking indices.