最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】redis中如何用列表保存数据+从列表中删除一个元素

redis crifan 3348浏览 0评论

redis store list

An introduction to Redis data types and abstractions – Redis

Data types – Redis

LPUSH mylist a   # now the list is “a”
LPUSH mylist b   # now the list is “b”,”a”
RPUSH mylist c   # now the list is “b”,”a”,”c” (RPUSH was used this time)

-》可以用list

LPUSH和RPUSH去保存数据到list

但是其所支持的操作中:

Command reference – Redis

却没有希望的:

DELETE之类的命令,可以直接删除list中的某个元素

redis list delete single item

remove element from list by it index – Google Groups

提到了LSET

redis LSET

Redis List Lset Command

Redis Sets

LSET — Redis 命令参考

List(列表) — Redis 命令参考

Redis 命令参考 — Redis 命令参考

Set(集合) — Redis 命令参考

SREM — Redis 命令参考

【总结】

终于找到了:

Redis中的SET集合,可以方便的SADD(=set add)存入和SREM(=set remove)删除单个元素

SADD — Redis 命令参考

SREM — Redis 命令参考

SMEMBERS — Redis 命令参考

转载请注明:在路上 » 【已解决】redis中如何用列表保存数据+从列表中删除一个元素

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.265 seconds, using 22.04MB memory