Questions tagged [redis-cli]

redis-cli is the command line interface that is installed when installing Redis.

redis-cli 3.0.5

Usage: redis-cli [OPTIONS] [cmd [arg [arg ...]]]
  -h <hostname>      Server hostname (default: 127.0.0.1).
  -p <port>          Server port (default: 6379).
  -s <socket>        Server socket (overrides hostname and port).
  -a <password>      Password to use when connecting to the server.
  -r <repeat>        Execute specified command N times.
  -i <interval>      When -r is used, waits <interval> seconds per command.
                     It is possible to specify sub-second times like -i 0.1.
  -n <db>            Database number.
  -x                 Read last argument from STDIN.
  -d <delimiter>     Multi-bulk delimiter in for raw formatting (default: \n).
  -c                 Enable cluster mode (follow -ASK and -MOVED redirections).
  --raw              Use raw formatting for replies (default when STDOUT is
                     not a tty).
  --no-raw           Force formatted output even when STDOUT is not a tty.
  --csv              Output in CSV format.
  --stat             Print rolling stats about server: mem, clients, ...
  --latency          Enter a special mode continuously sampling latency.
  --latency-history  Like --latency but tracking latency changes over time.
                     Default time interval is 15 sec. Change it using -i.
  --latency-dist     Shows latency as a spectrum, requires xterm 256 colors.
                     Default time interval is 1 sec. Change it using -i.

  --lru-test <keys>  Simulate a cache workload with an 80-20 distribution.

  --slave            Simulate a slave showing commands received from the master.
  --rdb <filename>   Transfer an RDB dump from remote server to local file.
  --pipe             Transfer raw Redis protocol from stdin to server.
  --pipe-timeout <n> In --pipe mode, abort with error if after sending all data.
                     no reply is received within <n> seconds.
                     Default timeout: 30. Use 0 to wait forever.
  --bigkeys          Sample Redis keys looking for big keys.
  --scan             List all keys using the SCAN command.
  --pattern <pat>    Useful with --scan to specify a SCAN pattern.
  --intrinsic-latency <sec> Run a test to measure intrinsic system latency.
                     The test will run for the specified amount of seconds.
  --eval <file>      Send an EVAL command using the Lua script at <file>.
  --help             Output this help and exit.
  --version          Output version and exit.

Examples:
  cat /etc/passwd | redis-cli -x set mypasswd
  redis-cli get mypasswd
  redis-cli -r 100 lpush mylist x
  redis-cli -r 100 -i 1 info | grep used_memory_human:
  redis-cli --eval myscript.lua key1 key2 , arg1 arg2 arg3
  redis-cli --scan --pattern '*:12345*'

  (Note: when using --eval the comma separates KEYS[] from ARGV[] items)

When no command is given, redis-cli starts in interactive mode.
Type "help" in interactive mode for information on available commands.
278 questions
3
votes
1 answer

Up arrow key not toggling commands within redis-cli (linux server)

On a Ubuntu-based production server, I usually toggle through redis keys inside redis-cli by just pressing the up arrow key. I suddenly find that this isn't working any more. Ergo, there's nothing shown after pressing the up arrow key, even if I've…
Hassan Baig
  • 15,055
  • 27
  • 102
  • 205
3
votes
1 answer

Redis encoding of objects and the size impact

When I write some objects to redis I can get different memory usage stats. I want to understand how this happens. Simple example: 127.0.0.1:6379> set a 1 OK 127.0.0.1:6379> MEMORY usage a (integer) 49 127.0.0.1:6379> set a "1" OK 127.0.0.1:6379>…
Avba
  • 14,822
  • 20
  • 92
  • 192
3
votes
1 answer

Get the redis key-value size in memory

I'm trying to get the size of a key-value or just a key or just a value in redis. Using debug object key command returns the serialized size of a key-value if it were to be written to disk and not the actual amount of bytes it is using in…
Avba
  • 14,822
  • 20
  • 92
  • 192
3
votes
1 answer

Could not connect to Redis at 127.0.0.1:0: Connection refused (when using init script to shut down a redis server w/ unix socket)

I can't shut down my redis server via the init script. This has the huge side effect of hanging my machine when I do sudo reboot. I freshly installed redis using the canonical guide, configured it to accept connections on a unix socket, and am now…
Hassan Baig
  • 15,055
  • 27
  • 102
  • 205
3
votes
1 answer

Why Redis keys are not expiring?

I have checked these questions but they did not help me to fix my issue. I am using Redis as a key value store for Rate Limiting in my Spring REST application using spring-data-redis library. I test with huge load. In that I use the following code…
prashanth-g
  • 1,183
  • 2
  • 13
  • 28
3
votes
2 answers

Correct shutdown sequence for Redis cluster

Suppose I have the following Redis replication setup: 3 machines Each machine has a Redis server and a Redis sentinel. One of the servers is set as master, the other two are its slaves. What would be the correct sequence and commands to…
odedia
  • 931
  • 2
  • 11
  • 27
3
votes
2 answers

Redis-cli command to restart the redis server

I terminated the redis server using SHUTDOWN from redis-cli. Now the prompt shows 'not connected>'. The only way I found to restart the server was to exit the redis-cli prompt and then do a restart of the redis service. My question is, is there any…
Adarsh Philip
  • 69
  • 1
  • 1
  • 7
3
votes
1 answer

redis-cli do a ttl command with a pattern

I want to display the ttl of all the keys I have in Redis at once from the redis-cli shell. I tried things like redis-cli keys * | xargs redis-cli TTL But it's not working, I keep getting the error: (error) ERR wrong number of arguments for…
Amaynut
  • 4,091
  • 6
  • 39
  • 44
2
votes
1 answer

How to configure Redis clients when connecting to master-replica setup?

I have a Redis setup with 1 master and 2 replicas - so totally 3 nodes. Given that writes can happen only via master node while reads can happen via all 3 nodes, how do I configure the clients? Can I pass all nodes IP in the IP list and the client…
Ankit Sahay
  • 1,710
  • 8
  • 14
2
votes
0 answers

redis-cli command not working as expected on windows machine

I am using a redis-cli command to bulk insert data and save response to a file using cat file.txt | redis-cli -h 192.168.100.28 --pipe >result.txt on windows type file.txt | redis-cli -h 192.168.100.28 --pipe >result.txt Then on Linux i can see…
uddi baba
  • 135
  • 2
  • 13
2
votes
1 answer

`redis-cli keys *` shows empty array, but `redis-cli keys my_key` shows the key

I have a redis server running in a Docker container. I push values to a list in there from an outside script. When I'm in the redis container, however, redis-cli keys * returns (empty array). This isn't an issue with selecting the correct database,…
Drake
  • 63
  • 8
2
votes
1 answer

How to connect Amazon ElastiCache for Redis nodes enabled with in-transit encryption using redis-cli from windows server and/ from redis GUI client

I have a AWS elasticache(cluster mode disabled) with encryption at rest & encryption-in-transit enabled and trying to use redis-cli to connect from windows server (within same vpc). Trying to connect to the RedisCluster from the server by following…
2
votes
0 answers

How do I find the eviction rate of keys in redis?

My redis cluster is configured with maxmem. The eviction policy is allkeys-lru. I want to know how long the keys are lasting on average before they are evicted. Every time a key is evicted, doesn't redis capture how long it lived for? I was…
Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
2
votes
1 answer

Error while using Redis Expire command options

I am trying to set expiry on a key if expiry is not already set by using NX option of Expire command. But I keep getting error from redis-cli, and when I try from code NX option gets ignored. When I try to use Expire command from redis-cli I get…
sachin p
  • 25
  • 4
2
votes
1 answer

Saving filtered redis-cli output to a file

I am trying to find when and how the cache is flushed, planned to use the command redis-cli monitor | grep -iE "del|flush" > redis_log.txt for that, but for some reason the file is empty. If i use the command without > redis_log.txt part - it shows…
kom93__
  • 57
  • 5