Caching Redis का सबसे सामान्य use case है — बार-बार एक्सेस होने वाले डेटा को तेज़ memory में स्टोर करना ताकि applications धीमी operations (database queries, API calls, computations) से बच सकें। बुनियादी caching pattern को समझना आवश्यक रोज़मर्रा का ज्ञान है।
cache-aside pattern (सबसे सामान्य)
1. App needs data → CHECK Redis first (cache lookup)
2. CACHE HIT (found) → return it immediately (fast!) ✓
3. CACHE MISS (not found) → query the database, store the result in Redis (with TTL),
then return it. Next time it'll be a hit.
() {
cached = redis.();
(cached) .(cached);
user = db..(id);
redis.(, .(user), , );
user;
}
