更新时间:2022-05-17 10:26:38
您的选项如下:
LREM
并在找到后替换它.SET
与您的 LIST
LIST
,直到找到项目或到达结尾.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 列表作为 http://en.wikipedia.org/wiki/Linked_list 实现,因此存在局限性.
Redis lists are implemented as a http://en.wikipedia.org/wiki/Linked_list, hence the limitations.
我认为您***的选择是维护一个重复的 SET
.这是我倾向于做的.把它想象成一个额外的索引.无论如何,请确保您的操作是使用 MULTI
-EXEC
或 Lua 脚本的原子操作.
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.