Redis powers everything from session storage to real-time leaderboards, but its 300+ commands are a lot to remember. A command builder organizes operations by data type and use case, showing you the exact syntax with examples you can copy and run.
What Is Redis Command Builder?
A Redis command builder helps you construct Redis commands for all data types: strings (GET/SET), hashes (HGET/HSET), lists (LPUSH/RPOP), sets (SADD/SMEMBERS), sorted sets (ZADD/ZRANGE), and more. It includes TTL settings, pattern matching, and pipeline/transaction examples.
How to Use Redis Command Builder on DevToolHub
- Open the Redis Command Builder tool on DevToolHub — no signup required.
- Select the Redis data type you're working with (String, Hash, List, Set, Sorted Set).
- Choose the operation (read, write, delete, search).
- Fill in the key name, value, and optional parameters (TTL, score, etc.).
- View the generated command with syntax explanation.
- Copy the command for use in redis-cli, Node.js, or Python.
Session Storage with TTL
Store user sessions with automatic expiration:
// Set a session with 30-minute TTL
SET session:user42 '{"userId":42,"role":"admin"}' EX 1800
// Check remaining time
TTL session:user42
// Returns: 1742 (seconds remaining)
// Refresh on activity
EXPIRE session:user42 1800
// Node.js:
await redis.set('session:user42', JSON.stringify(data), 'EX', 1800);Sessions auto-expire after 30 minutes of inactivity — no cleanup cron job needed.
Leaderboard with Sorted Sets
Build a real-time game leaderboard:
// Add player scores
ZADD leaderboard 1500 "alice"
ZADD leaderboard 2200 "bob"
ZADD leaderboard 1800 "charlie"
// Top 10 players (highest first)
ZREVRANGE leaderboard 0 9 WITHSCORES
// Player rank (0-based)
ZREVRANK leaderboard "alice"
// Returns: 2 (third place)
// Increment score
ZINCRBY leaderboard 500 "alice"Sorted sets maintain order automatically — no re-sorting needed after score updates.
Rate Limiting with Lua Script
Implement sliding-window rate limiting:
-- Check and increment request count
local key = KEYS[1]
local limit = tonumber(ARGV[1])
local window = tonumber(ARGV[2])
local current = tonumber(redis.call('GET', key) or '0')
if current >= limit then
return 0 -- Rate limited
end
redis.call('INCR', key)
redis.call('EXPIRE', key, window)
return 1 -- AllowedLua scripts execute atomically in Redis — no race conditions between check and increment.
Pro Tips
- Use key namespaces — prefix keys with
type:entity:id(e.g.,session:user:42) for organized data. - Set TTL on everything — unbounded keys fill memory; default to expiration and make exceptions for permanent data.
- Pipeline batch operations — sending 100 commands in a pipeline is 10x faster than 100 individual round trips.
- Monitor memory — use
INFO memoryandMEMORY USAGE keyto track Redis memory consumption.
When You Need This
- Implementing user session storage with automatic expiration
- Building real-time leaderboards and ranking systems
- Setting up rate limiting for API endpoints
- Caching expensive database queries with configurable TTL
Free Tools Mentioned in This Article