Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to pop all list items from redis list at once?

I want to pop all list items from redis list at once.

I don't want to call lpop or rpop method by when the list is empty because it seems to be inefficient sending requests multi-time to redis-server.

I also know that I can get all lists with lrange method but not popping items.

Could you suggest me?

I just want to pop and get items in a list by one request to redis-server.

like image 924
SangminKim Avatar asked Mar 13 '23 18:03

SangminKim


1 Answers

As Itamar Haber said, use lrange and del. In pipe mode it will be done as a single command.

LRANGE key 0 -1
DEL key
like image 58
h0x91B Avatar answered Apr 27 '23 23:04

h0x91B