redis-cli -h localhost -p 6379
127.0.0.1:6379> SET greeting 'hello'
127.0.0.1:6379> GET greeting
Topics
40
Caching Patterns
Cluster Sharding & Hash Slots
Clustering
Connection Pooling & Client Libraries
Data Types
Distributed Locks with Redis
Expiration & Eviction
Geospatial Data in Redis
Hashes in Redis
HyperLogLog in Redis
Keyspace Notifications
Leaderboards with Sorted Sets
Lists in Redis
Lua Scripting
Persistence (RDB/AOF)
Pub/Sub
Rate Limiting with Redis
Redis Architecture & Installation
Redis as a Message Queue
Redis Backup & Disaster Recovery
Redis CLI & Basic Commands
Redis Memory Optimization
Redis Modules Overview
Redis Monitoring & Observability
Redis Performance Tuning & Benchmarking
Redis Replication
Redis Security & ACL
Redis Sentinel & High Availability
Redis vs Memcached
Redis with Docker & Kubernetes
RedisBloom (Probabilistic Data Structures)
RedisJSON
RedisSearch (Full Text Search)
RedisTimeSeries
Session Management with Redis
Sets & Sorted Sets in Redis
Streams
Strings & Bitmaps in Redis
TLS & Encryption in Redis
Transactions
Redis CLI & Basic Commands
7 questions found
redis-cli is the official command line tool for connecting directly to a Redis server, letting you run commands interactively and see their results immediately, which is useful for quick testing, troubleshooting, and learning how specific commands behave before using them in application code.
Real-world example
A developer uses redis-cli to quickly test how a new command behaves before writing the equivalent code in their application, confirming the exact syntax and expected response format.
Redis Architecture & Installation;Redis Security & ACL
SET stores a value under a specified key, GET retrieves the current value stored under a specified key, and DEL removes one or more keys entirely from Redis, together forming the fundamental building blocks for storing, retrieving, and removing simple data.
SET username 'alice'
GET username
DEL username
Real-world example
A simple caching layer uses SET to store a computed result, GET to quickly retrieve it on subsequent requests, and DEL to remove it once it is no longer needed or has become outdated.
Data Types;Expiration & Eviction
How do you search for keys matching a specific pattern in Redis, and why is the KEYS command generally discouraged in production?
IntermediateYou can use the KEYS command with a wildcard pattern to find matching key names, but it is generally discouraged in production because it scans the entire keyspace in a single blocking operation, which can significantly slow down the server on a large dataset, and the SCAN command is recommended instead since it iterates through the keyspace incrementally without blocking.
-- Avoid in production on a large dataset
KEYS user:*
-- Preferred alternative
SCAN 0 MATCH user:* COUNT 100
Real-world example
A team investigating a brief production slowdown discovers a monitoring script had been calling KEYS on a large dataset, and switches it to use SCAN instead, eliminating the blocking behavior that was causing the issue.
Redis Memory Optimization;Redis Performance Tuning & Benchmarking
How do you check basic information about a Redis key, such as its data type and remaining time to live?
IntermediateYou use the TYPE command to see what kind of data type a key holds, such as string, list, or hash, and the TTL command to see how many seconds remain before the key automatically expires, returning a negative value if the key either has no expiration set or does not exist at all.
TYPE mykey
TTL mykey
Real-world example
A developer debugging an issue where cached data seemed to disappear too quickly checks the TTL of several keys, discovering an expiration time had been set much shorter than intended.
Expiration & Eviction;Data Types
How would you use redis-cli's built-in monitoring and debugging features to troubleshoot a live performance issue on a production Redis instance?
AdvancedYou could use the MONITOR command to see a live stream of every command being processed by the server, though carefully since it adds overhead and should be used briefly, the SLOWLOG command to review commands that have taken longer than a configured threshold to execute, and the LATENCY tool to identify specific sources of delay within Redis's internal operations.
redis-cli slowlog get 10
redis-cli latency history command
Real-world example
A team investigating intermittent slow responses uses SLOWLOG to identify a specific command pattern that was consistently taking much longer than expected, quickly pinpointing the root cause of their performance issue.
Redis Performance Tuning & Benchmarking;Redis Monitoring & Observability
How do you use redis-cli in scripting mode to automate repetitive administrative tasks rather than running commands interactively?
AdvancedYou can pass commands directly as arguments to redis-cli for a single non interactive execution, or pipe a series of commands from a file, letting you build automated scripts for tasks like bulk data loading, scheduled maintenance operations, or integrating Redis commands into larger shell based automation workflows.
redis-cli set mykey myvalue
cat commands.txt | redis-cli
Real-world example
An operations team automates a routine cleanup task by writing a script that pipes a series of Redis commands through redis-cli, running it as a scheduled job without any manual interactive steps required.
Redis Performance Tuning & Benchmarking;Connection Pooling & Client Libraries
How do you use the EXISTS and RENAME commands, and what should you be careful about when using RENAME?
IntermediateEXISTS checks whether one or more specified keys are currently present in Redis, returning a count of how many of them actually exist, while RENAME changes an existing key's name, but you should be careful since RENAME will silently overwrite any existing key that already has the new target name, potentially causing accidental data loss.
EXISTS mykey
RENAME oldname newname
Real-world example
A developer accidentally overwrites important cached data using RENAME, learning to first check with EXISTS or use RENAMENX, which only renames if the target name does not already exist, to avoid this kind of mistake in the future.
Data Types;Redis CLI & Basic Commands