Caching Redis کا سب سے عام استعمال ہے — بار بار رسائی والے ڈیٹا کو تیز میموری میں محفوظ کرنا تاکہ applications سست operations سے بچ سکیں (ڈیٹابیس 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;
}
