LMOVE

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

Move an element between lists

Pops an element from the source list and pushes it to the destination list.
Specify left/right when popping from the source list, and specify left/right when pushing to the destination list. LEFT can be read as the first or head of the list, and RIGHT as the last or tail of the list.

Example: Reliable queue

Command>lpush src_key msg_1 msg_2 msg_3
Result>3
Command>lpush dest_key msg_A msg_B msg_C
Result>3
Command>lmove src_key dest_key left left
Result>msg_3
Command>lrange src_key 0 -1
Result> 1) "msg_2"
2) "msg_1"
Command>lrange dest_key 0 -1
Result> 1) "msg_3"
2) "msg_C"
3) "msg_B"
4) "msg_A"


Syntax

LMOVE source destination LEFT|RIGHT LEFT|RIGHT

  • Available since version 6.2.0.
  • Time complexity is O(1).
Related commands BLMOVE

<< LTRIM LMOVE RPOPLPUSH >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.