Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 403
einnocent Avatar asked Dec 29 '13 20:12

einnocent


People also ask

How do I get all Redis values?

To list the keys in the Redis data store, use the KEYS command followed by a specific pattern. Redis will search the keys for all the keys matching the specified pattern.

How do I view a list in Redis?

Redis Get List Items. To get elements in a Redis, use the LRANGE command. This command takes the name of the list and the index range of the element you wish to access. The command should return the values of the elements in the specified range.

How do I view the contents of Redis cache?

You can check the actual number by running redis-cli config get databases. In interactive mode, the database number is displayed in the prompt within square braces. For example, 127.0. 0.1:6379[13] shows that the 13th database is in use.

Which command is used to obtain all the keys in a Redis database?

You can use COMMAND GETKEYS or COMMAND GETKEYSANDFLAGS to discover key names directly from how Redis parses the commands.


1 Answers

You use -1 to indicate end of list so:

LRANGE key 0 -1 

would print all.

like image 179
Zitrax Avatar answered Sep 17 '22 12:09

Zitrax