How to remove element from list in Redis by value?

Faud picture Faud · May 31, 2015 · Viewed 16.6k times · Source

How to remove element from list in Redis by value?

For exmaple, I have:

127.0.0.1:6379> lrange POST:544 0 -1
1) "1"
2) "2"
3) "36"
127.0.0.1:6379> 

I know only value 36, not index. Can I remove element from list by value?

Answer

Karthikeyan Gopall picture Karthikeyan Gopall · Jun 1, 2015

http://redis.io/commands/lrem

Lrem is what you are looking for. use LREM POST:544 1 36.