Redis的底层类型之list

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  

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

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

你可能感兴趣的:(redis学习笔记)