What is Redis Cache?
๐ก Concept Name
Redis Cache โ A fast, open-source, in-memory key-value store used as a database, cache, and message broker.
๐ Quick Intro
Redis is often used as a distributed cache to improve app performance. It stores data in memory, making reads and writes extremely fast compared to databases.
๐ง Analogy / Short Story
Imagine a high-speed express lane for data โ instead of going through the entire store (database), Redis gives you what you need from a shelf right in front of you.
๐ง Technical Explanation
- ๐ฆ Stores key-value pairs in memory (RAM).
- โก Extremely fast access times (sub-millisecond).
- ๐ง Supports strings, hashes, lists, sets, sorted sets.
- ๐ Works across distributed systems for scaling.
- ๐ TTL, eviction policies, and persistence options available.
๐ฏ Purpose & Use Case
- โ Caching API responses or session data.
- โ Real-time analytics and leaderboard tracking.
- โ Queueing, pub/sub messaging, and data streaming.
๐ป Real Code Example
// Example using StackExchange.Redis
var redis = ConnectionMultiplexer.Connect("localhost");
IDatabase db = redis.GetDatabase();
string key = "user:1:name";
db.StringSet(key, "Alice");
string name = db.StringGet(key);
Console.WriteLine(name); // Output: Alice

โ Interview Q&A
Q1: What is Redis?
A: An in-memory data store used for caching, databases, and pub/sub messaging.
Q2: Why is Redis fast?
A: It operates entirely from memory and avoids disk I/O.
Q3: Is Redis distributed?
A: Yes, it supports clustering and replication.
Q4: Does Redis support expiration of keys?
A: Yes, using TTL (Time To Live).
Q5: What data structures does Redis support?
A: Strings, hashes, lists, sets, sorted sets, bitmaps, streams, etc.
๐ MCQs
Q1. What type of store is Redis?
- SQL DB
- File system
- In-memory key-value store
- Blob storage
Q2. Which protocol does Redis use?
- HTTP
- RESP
- SOAP
- MQTT
Q3. What is Redis used for?
- Only DB storage
- File compression
- Caching and messaging
- Image processing
Q4. What data type can Redis store?
- Only strings
- Only int
- Strings, lists, sets
- Only JSON
Q5. Is Redis persistent?
- Always
- Never
- Optional
- Depends on RAM
Q6. What is TTL in Redis?
- Time Taken Load
- Timeout Transfer Line
- Time To Live for a key
- Token Time Log
Q7. Which company maintains Redis?
- Microsoft
- Redis Ltd.
- Apache
Q8. Which library is used in .NET?
- RedisSharp
- StackExchange.Redis
- Redis.NET
- System.Redis
Q9. What happens when memory is full?
- App crashes
- Redis auto-expands
- Eviction based on policy
- It flushes DB
Q10. What is Redis pub/sub?
- Memory backup
- Data storage only
- Message broadcasting model
- File upload system
๐ก Bonus Insight
Redis offers blazing performance but beware of memory limitations. Use eviction strategies like LRU to balance memory and freshness.
๐ PDF Download
Need a handy summary for your notes? Download this topic as a PDF!