Checking if a value exists in a list already Redis

后端 未结 5 1777
深忆病人
深忆病人 2021-02-01 13:14

I\'m wondering if there\'s a way to check if a key already exists in a redis list?

I can\'t use a set because I don\'t want to enforce uniqueness, but I do want to be ab

5条回答
  •  甜味超标
    2021-02-01 13:47

    No, there is no way to check if a redis list contains a given value. See Redis list commands for reference.

    I guess you could use LREM to (try to) remove the value, and check the return value to see if it was removed. But then you would have to put it back in, and this seems iffy. There is probably some better solution to your problem - what are you trying to accomplish?

提交回复
热议问题