Welcome to Instant-Search ⚡
Deep dive into cache-related concepts with an application allowing you to search for software development tags.
Feel the impact of three-tier caching while you type. ⌨️
Every keystroke flows through LRU → Redis → Postgres, and the UI streams live hit/miss counters and latency charts so you can watch hot prefixes bubble up the stack in real time. The entire demo fits comfortably inside free-tier quotas and seeds itself from a single CSV in seconds.
Under the hood:
- L1:
lru-cache
(key-value in-memory store, per instance, short term) - L2: Redis (key-value store, shared, long term)
- DB (L3): Postgres (materialized view, shared, persisted)
- Render Web Service, Free tier
- 750 instance-hours / month; spins down after 15 minutes of idle time.
- Bandwidth: 100 GB / month
- Build: 500 min / month
- Custom Domains.
- Managed TLS certificates.
- lru-cache
- Type: In-process cache, part of the Backend and Frontend instance.
- Straightforward, battle-tested implementation.
- Single-flight behavior is available via fetch() and SWR patterns.
- Easy to add TTL jitter by wrapping
.set()
with a jittered TTL generator.
- Upstash Redis, Free tier
- Type: Lambda (Serverless)
- One free DB per account.
- Commands/API Calls: 500K / month
- Bandwidth: 10 GB / month
- Storage: 256 MB
- Supabase PostgreSQL, Free tier
- Type: Instance
- Free projects are paused after 1 week of inactivity; Max 2 active projects.
- Commands/API Calls: Unlimited
- Bandwidth: 5 GB / month
- Storage: 500 MB DB, 1 GB files
- RAM: 500 MB
- Seed DB with data from
StackOverflow: Tags with Popularity query
- Table name:
tags
- Columns:
TagName,Mentions,SynonymsCount,SynonymsJSON,ExcerptID,Excerpt,WikiID,Wiki
- Table name:
- Create a Materialized View
- A DB object that stores the result of a query on disk (or in memory) so it can be read like a regular table.
- Break down the
tags
corpus to prefixes - Will allow time complexity of O(1) for reads
- Table name:
suggestions
- Columns:
prefix,suggestions
- Cap
prefix
length to 6 characters to keep row count reasonable (50k tags × 6 prefixes = 300k rows) - Order the
suggestions
based onMentions
prefix
needs to betext PRIMARY KEY
so can create a btree index on it- Limit to 10 suggestions
- Example:
j,[javascript,java,jquery...]
- (optional) Setup automatic refresh for the Materialized View every 24 hours