32

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.

2
  • Note mods: this post needs the tag redis-cli Commented Dec 29, 2013 at 20:33
  • redis-cli is a new tag ... is it really needed to differentiate between redis and redis-cli? Commented Jan 1, 2014 at 0:32

2 Answers 2

65

You use -1 to indicate end of list so:

LRANGE key 0 -1 

would print all.

Sign up to request clarification or add additional context in comments.

Comments

0

Here's how I did it with python:

import redis r_server = redis.Redis() for num in "one", "two", "three", "four", "five": r_server.rpush("nums", num) length = r_server.llen("nums") for x in range(0,length): print(str(r_server.lindex("nums",x))) b'one' b'two' b'three' b'four' b'five' 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.