The problem
Typeahead has to respond on every few keystrokes while ranking suggestions from historical and recent activity. Writing every search event immediately creates unnecessary storage pressure.
Caching reduces read cost, but the design must decide where keys live, what to invalidate after writes, and what happens when a cache node cannot respond.
The solution
A Spring Boot service queries a 120,000-row local SQLite dataset, aggregates search events in memory, writes them in batches, and supports overall and recency-weighted trending ranking.
Suggestion keys route across three standalone Redis nodes using SHA-256 consistent hashing with virtual nodes. Reads fall back to SQLite when Redis is unavailable.