user2326568
user2326568

Reputation: 355

select all and truncate redis database

I'm looking for something similar to BLPOP, but instead of element I want to get them all run running over them in a loop. It means that I want to get all the records of redis collection, and truncate it.

Upvotes: 0

Views: 181

Answers (1)

thepirat000
thepirat000

Reputation: 13089

Consider using a LUA script to do the LRANGE+DEL atomically.

Or use RENAME to move the list to a temporary key which you will use to process the data.

RENAME yourlist temp-list
LRANGE temp-list 0 -1
... process the list
DEL temp-list

Upvotes: 1

Related Questions