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
Your options are as follows:
LREM
and replacing it if it was found.SET
in conjunction with your LIST
LIST
until you find the item or reach the end.Redis lists are implemented as a http://en.wikipedia.org/wiki/Linked_list, hence the limitations.
I think your best option is maintaining a duplicate SET
. This is what I tend to do. Just think of it as an extra index. Regardless, make sure your actions are atomic with MULTI
-EXEC
or Lua scripts.