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
670
votes
16 answers

Redis command to get all available keys?

Is there a Redis command for fetching all keys in the database? I have seen some python-redis libraries fetching them. But was wondering if it is possible from redis-client.
Lalith
  • 19,396
  • 17
  • 44
  • 54
85
votes
6 answers

Remove complete hashset at once in redis

I have a hash in Redis named "match/123/result". I am adding entries to this hash using HSET and retrieving all entries at once using HGETALL. I want to flush this hash, but there is no command like "HDELALL" (in redis-cli). I am therefore using DEL…
Pranav
  • 2,054
  • 4
  • 27
  • 34
80
votes
1 answer

Redis Pubsub and Message Queueing

My overall question is: Using Redis for PubSub, what happens to messages when publishers push messages into a channel faster than subscribers are able to read them? For example, let's say I have: A simple publisher publishing messages at the rate…
Marco Benvoglio
  • 1,283
  • 2
  • 12
  • 17
36
votes
2 answers

Can I use redis-cli with a connection URL?

I am used to psql which I can use by feeding it the connection string without having to break it in different arguments, that is, psql postgres://:@: This is useful when I have such string from Heroku, for…
Alessandro Cosentino
  • 2,268
  • 1
  • 21
  • 30
28
votes
2 answers

How to print all values in a list with redis-cli without knowing the size of the list?

In redis-cli, what is the command to print all the values in a list without knowing in advance the size of the list? I see lrange, but it requires naming the start index and the end index.
einnocent
  • 3,567
  • 4
  • 32
  • 42
22
votes
2 answers

Understanding latency using Redis-Cli

I'm using the redis-cli tool to observe redis-server latency. Here's an example: ubuntu:~$ redis-cli --latency -h 127.0.0.1 -p 6379 min: 0, max: 15, avg: 0.12 (2839 samples) Question is, what these values actually mean? I'm struggling to find…
Marco Benvoglio
  • 1,283
  • 2
  • 12
  • 17
20
votes
6 answers

Saving Redis query output to file

Using redis-cli I connected to specific server: redis-cli -h 10.1.xx.xx And select 1 Then just to get list of one key features: KEYS data_column* THis will print list of that column values on command line. However, there are like quite many values,…
xavi
  • 327
  • 1
  • 5
  • 13
19
votes
4 answers

How to delete keys matching a certain pattern in redis

How to delete keys matching a certain pattern in redis using redis-cli. I would like to delete all foo's from the following list. KEYS * foo:1 foo:2 bar:1 foo:3 bar:2 foo:4
Rpj
  • 5,348
  • 16
  • 62
  • 122
13
votes
5 answers

Get all hashes exists in redis

I'm have hashes in redis cache like: Hash Key Value hashme:1 Hello World hashme:2 Here Iam myhash:1 Next One My goal is to get the Hashes as output in the CLI like: hashme myhash If there's no such option, this is ok…
ohadinho
  • 6,894
  • 16
  • 71
  • 124
12
votes
1 answer

How to get value by redis-cli keys

I want get value by redis-cli keys This is work redis-cli keys number_* | xargs redis-cli del But this is not work redis-cli keys number_* | xargs redis-cli get
weiwei
  • 123
  • 1
  • 1
  • 4
12
votes
7 answers

Redis cli delete multiple keys

I have installed Redis in centos and I have multiple keys of redis like this, Product:: How can I delete all Product:*:* with CLI ? Redis version : 3.2.4 [ Latest I guess ] Thanks!
John FG
  • 131
  • 1
  • 1
  • 6
9
votes
3 answers

redis: Create cluster with redis-cli non interactively

When trying to create a cluster with redis-cli as follows redis-cli --cluster create a prompt comes up asking for configuration confirmation? Is there a way to script this (preferably in ansible) and run it non-interactively? I am aware of this…
pkaramol
  • 16,451
  • 43
  • 149
  • 324
9
votes
3 answers

Redis setting TTL on hSet Keys

I am on an dead end with redis cache. I want to set an TTL on the initiation of a key. The key will be set by hSet($hash, $key, $data) expire($key, '3600') does not seem to work. Is there an hExpire() method?
Isengo
  • 2,004
  • 3
  • 21
  • 43
9
votes
0 answers

Copy redis database (.rdb file) from a remote server to local

I was given a Redis server that is set up remotely. I can access data in that and I can do CRUD operation with that server. But I want the replica of the same database in my local. I have Redis desktop manager setup in my local. And also…
abhi
  • 115
  • 1
  • 8
8
votes
0 answers

How to decode value in redis cli or shell script

I've written redis-cli bash script to process all key and value for bulk retrieval but values are not printing as expected. When I give my key in redis-cli its printing with all special characters: My Key and output from redis-cli redis-cli MGET…
learn java
  • 231
  • 3
  • 14
1
2 3
18 19