| N+1 Query Problem QA :👈 | 👉:NET-Core-Native-AOT |
Redis Interview Questions and Answers for ASP.NET Core Developers |
ASP.NET Core Distributed Caching with Redis Interview Questions
35. Interview Questions and Answers
1. What is distributed caching?
Distributed caching stores frequently accessed data in an external cache shared by multiple application instances.
2. Why use Redis with ASP.NET Core?
Redis provides fast in-memory data access and allows multiple application instances to share cached data.
3. What is IDistributedCache?
IDistributedCache is an ASP.NET Core abstraction that provides common methods for storing and retrieving data from a distributed cache provider.
4. Is AddDistributedMemoryCache a real distributed cache?
No. It implements IDistributedCache but stores data in the memory of each application instance.
5. What is cache-aside?
Cache-aside means the application checks the cache first, retrieves data from the database on a miss, and then stores the result in the cache.
6. What is a cache hit?
A cache hit occurs when the requested key exists in Redis and the cached value can be returned.
7. What is a cache miss?
A cache miss occurs when the requested key does not exist or has expired.
8. What is cache invalidation?
Cache invalidation is the process of removing or updating cached values when the original data changes.
9. What is cache stampede?
A cache stampede occurs when many requests attempt to reload the same expired or missing cache entry simultaneously.
10. How can you prevent cache stampede?
Use request coalescing, local locks, distributed coordination where necessary, cache warming, and suitable expiration strategies.
11. What is the difference between absolute and sliding expiration?
Absolute expiration uses a fixed expiration time. Sliding expiration extends the expiration timeout when the entry is accessed.
12. Does Redis replace SQL Server?
No. Redis is generally used as a caching layer, while SQL Server remains the persistent source of truth.
13. Why should we use asynchronous cache methods?
Asynchronous methods avoid blocking request-processing threads while waiting for network I/O.
14. What happens if Redis becomes unavailable?
Cache operations may fail or time out. The application needs an appropriate failure strategy, such as a controlled database fallback for suitable operations.
15. Why should we use cache key versioning?
Versioned keys prevent new application code from accidentally reading entries created with an incompatible older data structure.
16. What is Redis TTL?
TTL means Time To Live. It represents the remaining lifetime of a Redis key before expiration.
17. What is ConnectionMultiplexer?
ConnectionMultiplexer is the StackExchange.Redis connection manager. It is designed to be shared and reused rather than recreated for every request.
18. What is the difference between IDistributedCache and StackExchange.Redis?
IDistributedCache is a general .NET caching abstraction. StackExchange.Redis is a Redis client library that also provides access to Redis-specific features.
19. Can Redis be used in microservices?
Yes. Microservices can use Redis for frequently accessed data, distributed session state, counters, and other appropriate caching scenarios.
20. What is the outbox pattern?
The outbox pattern stores a business update and an event record in the same database transaction. A background processor later publishes or processes the event reliably.
21. What is the difference between distributed caching and output caching?
Distributed caching stores application data. Output caching stores generated HTTP responses so the server can reuse them.
22. Should Redis store every database record?
No. Cache frequently accessed data that provides a measurable performance benefit. Caching everything wastes memory and increases maintenance complexity.
23. What is cache warming?
Cache warming means preloading frequently requested data into the cache before normal user traffic requests it.
24. How do you monitor Redis?
Monitor hit rate, miss rate, memory, evictions, latency, connected clients, network throughput and failed operations.
25. How do you handle stale cache data?
Use appropriate TTLs, remove or refresh entries after updates, and use reliable invalidation mechanisms for important data.
| N+1 Query Problem QA :👈 | 👉:NET-Core-Native-AOT |