Concept Flow - Key design patterns
Start: Choose Data Use Case
Select Pattern Type
Cache
Store Data
Retrieve Fast
End
This flow shows how Redis key design patterns are chosen based on use case, then applied to store, communicate, or control data.
SET user:1000 "Alice" GET user:1000 PUBLISH channel1 "Hello" INCR rate_limit:1000 EXPIRE rate_limit:1000 60
| Step | Command | Key/Channel | Action | Result/State Change |
|---|---|---|---|---|
| 1 | SET | user:1000 | Store value 'Alice' | user:1000 = 'Alice' |
| 2 | GET | user:1000 | Retrieve value | 'Alice' returned |
| 3 | PUBLISH | channel1 | Send message 'Hello' | Message 'Hello' sent to channel1 |
| 4 | INCR | rate_limit:1000 | Increment counter | rate_limit:1000 = 1 |
| 5 | EXPIRE | rate_limit:1000 | Set expiration 60s | rate_limit:1000 expires in 60 seconds |
| 6 | GET | rate_limit:1000 | Retrieve counter | '1' returned |
| 7 | WAIT 61s | - | Wait for expiration | rate_limit:1000 key expired |
| 8 | GET | rate_limit:1000 | Try retrieve expired key | nil (key not found) |
| Key | Start | After Step 1 | After Step 4 | After Step 5 | After Step 7 | Final |
|---|---|---|---|---|---|---|
| user:1000 | nil | 'Alice' | 'Alice' | 'Alice' | nil | nil |
| rate_limit:1000 | nil | nil | 1 | 1 (expires in 60s) | expired | nil |
Redis Key Design Patterns: - Use SET/GET for caching data. - Use PUBLISH/SUBSCRIBE for messaging. - Use INCR + EXPIRE for rate limiting. - EXPIRE auto-deletes keys after time. - Keys can store strings, counters, or messages. - Patterns help organize Redis usage clearly.