关于redis:Redis的底层类型之list

44次阅读

共计 577 个字符,预计需要花费 2 分钟才能阅读完成。

lists

Redis lists are linked lists of string values. Redis lists are frequently used to:
Redis 列表是由字符串值组成的链接列表。Redis 列表常常用于:

  • Implement stacks and queues. 实现堆栈和队列。
  • Build queue management for background worker systems. 构建后盾工作者零碎的队列治理。

常用命令

  • LPUSH

adds a new element to the head of a list; RPUSH adds to the tail.

  • LPOP

removes and returns an element from the head of a list; RPOP does the same but from the tails of a list.

  • LLEN
  • LMOVE
LMOVE source destination <LEFT | RIGHT> <LEFT | RIGHT>

atomically moves elements from one list to another.

  • LTRIM

    LTRIM key start stop

    Trim an existing list so that it will contain only the specified range of elements specified.

  • BLPOP
  • BLMOVE

如果源列表为空,这两个指令会阻塞期待

正文完
 0