Should I get the length of the list first and then query the list in Redis?

I want to know if only lrange can get the list in Redis ? It needs an end parameter, and if I want a complete list, I have to use llen to get the length first. Like this:

 redis.lrange("myList", 0, llen("myList")); 

Is there any method that can get the complete list directly?

+6
source share
1 answer

You can use -1 as the index of the last item. This will give you a complete list:

 lrange mylist 0 -1 

And this will get a complete list, but the last item

 lrange mylist 0 -2 

Etc...

By the way, all this is written in the documentation .

+19
source

Source: https://habr.com/ru/post/913303/


All Articles