Redis Interview Guide: Concepts, Caching, Persistence, Replication, and Sentinel

This article provides a comprehensive interview‑style walkthrough of Redis, covering its definition, data types, caching strategies with Spring Boot, performance characteristics, eviction policies, persistence mechanisms, master‑slave replication, and Sentinel high‑availability architecture.

Selected Java Interview Questions
Selected Java Interview Questions
Selected Java Interview Questions
Redis Interview Guide: Concepts, Caching, Persistence, Replication, and Sentinel

The interview begins with a brief definition of Redis as an open‑source, high‑performance, in‑memory key‑value store written in C, supporting use cases such as database, cache, and message broker.

Key Redis data types are introduced: String, Hash, List, Set, and Sorted Set, each with typical use cases and internal storage details.

Caching with Spring Boot is demonstrated using RedisTemplate and Spring Cache annotations (@Cacheable, @CachePut, @CacheEvict). Sample Maven dependencies, application.yml configuration, entity class User.java, custom cache configuration RedisCacheConfig.java, and controller code illustrate how to store and retrieve objects from Redis.

Common cache problems are discussed, including cache inconsistency, cache avalanche, cache penetration, and cache breakdown, along with mitigation strategies such as random expiration, hot‑key handling, Bloom filters, and mutex locks (code example provided).

The article explains why Redis is fast despite being single‑threaded: in‑memory operations (O(1) hash lookups), simple data structures, avoidance of context switches, and non‑blocking I/O multiplexing.

Differences between Redis and Memcached are highlighted: persistence, data type support, value size limits, and underlying architecture.

Redis eviction policies (volatile‑lru, allkeys‑lru, volatile‑ttl, volatile‑random, allkeys‑random, noeviction) and the newer LFU policies are listed.

Persistence mechanisms are covered: RDB snapshots (forking a child process to write a temporary dump file) and AOF (append‑only file with configurable fsync strategies). Their advantages, disadvantages, and typical usage scenarios are explained.

Master‑slave replication is described, including the replication handshake, full and partial synchronization using PSYNC, runId, offset, and replication backlog. Problems of single‑master architecture and the role of Sentinel for automatic failover, monitoring, and configuration provisioning are detailed with step‑by‑step workflow diagrams.

Finally, the article summarizes the covered topics, emphasizing the importance of thorough preparation for Redis‑related interview questions.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

sentinelspring-boot
Selected Java Interview Questions
Written by

Selected Java Interview Questions

A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.