Cheatsheet
Cheatsheet - CLI
CLI - Verify connection to Redis server
redis-cli -h $host -p $port pingUse cases
Query Cache
API Gateway Cache for user sessions
Pub/Sub
Redis Pub/Sub (Publish/Subscribe) is a messaging pattern where clients can subscribe to channels, and other clients can publish messages to these channels. Clients that are subscribed to a channel receive all the messages published to that channel. This messaging pattern is useful for broadcasting messages to multiple clients.
Good for real-time notifications, chat apps, or any use case where speed and simplicity are key.
Think of it like: A group chat where everyone hears what’s said, but once it’s said, it’s gone forever.
Redis Streams
-
Good for event sourcing, message queuing, and real-time data processing, similar to Apache Kafka
-
A data structure that acts like an append-only log.
-
The main advantages of Redis Streams are the highly efficient consumer groups, allowing groups of consumers to uniquely consume from different parts of the same stream of messages, and the blocking operations that allow a consumer to wait until a new data is added to the stream.
-
Resources
- Microservices Communication with Redis Streams (opens in a new tab)
- You’re Probably Thinking About Redis Streams Wrong (opens in a new tab)
- Harness - Event-Driven Architecture Using Redis Streams (opens in a new tab)
- What to Choose for Your Synchronous and Asynchronous Communication Needs—Redis Streams, Redis Pub/Sub, Kafka, etc. (opens in a new tab)
- Redis Streams vs Apache Kafka (opens in a new tab)
Cache-aside (Lazy-loading)
- Improves read performance
Write-Behind (Write-Back)
-
Improves write performance
-
Resources
Write-Through
Read-Replica
Resources
-
Redis Developer Hub (opens in a new tab)
Lots of tutorials and examples for various use cases
Managing Redis
Persistence
-
Redis persistence (opens in a new tab)
Different persistence strategies and performance implications
-
Redis Persistence Dive Deep - Trade-offs Between Performance And Durability (opens in a new tab)
Understanding AOF and RDB strategies, their trade-offs and applications
Spring Data Redis
Clients
-
Lettuce (opens in a new tab) is generally recommended.
- Officially supported
- Free for commercial use
- Decent performance
-
Redisson
- Many features missing only available to Pro version
- High performance
-
Jedis
- Easy to use
- Blocking I/O