backend / caching / README.md

Redis Caching

1 min read index source

Redis Caching

Redis is an in-memory data structure store used as a database, cache, and message broker.

Key Concepts

Data Types

  • Strings: Simple key-value pairs
  • Hashes: Field-value pairs within a key
  • Lists: Ordered collections of strings
  • Sets: Unordered collections of unique strings
  • Sorted Sets: Sets with scores for ordering
  • Streams: Log-like data structures (Redis 5.0+)

Caching Patterns

  1. Cache-Aside: Application manages cache
  2. Write-Through: Write to cache and database simultaneously
  3. Write-Behind: Write to cache first, then database
  4. Refresh-Ahead: Proactively refresh cache before expiration

Common Interview Questions

  1. What are the advantages of Redis over other caching solutions?
  2. Explain Redis persistence options (RDB vs AOF)
  3. How does Redis handle memory management?
  4. What is Redis clustering and how does it work?
  5. Explain Redis pub/sub mechanism
  6. How to implement distributed locking with Redis?
  7. What are Redis transactions and how do they work?
  8. How to handle cache invalidation strategies?
  9. Explain Redis data eviction policies
  10. How to implement rate limiting with Redis?
  11. What is Redis Sentinel and its purpose?
  12. How to handle Redis failover scenarios?