Module Hub Beta

LXSPLICE

srclist dstlist count [ATTACH end] [ORDER ASC|DESC|NOEFFORT]

Moves count from one end of srclist to one of dstlist‘s ends.

If less than count elements are available, it moves as much elements as possible.

A positive count removes elements from the head of srclist, and negative from its end. The optional ATTACH subcommand specifies the end of dstlist to which elements are added and end can be either 0 meaning list’s head (the default), or -1 for its tail.

To maintain the order of elements from srclist, LSPLICE may perform extra work depending on the count sign and end.

The optional ORDER subscommand specifies how elements will appear in destlist. The default ASC order means that the series of attached elements will be ordered as in the source list from left to right. DESCwill cause the elements to be reversed. NOEFFORT avoids the extra work, so the order determined is:

count end NOEFFORT
+ 0 DESC
0 ASC
+ -1 ASC
-1 DESC

Return Value

Integer reply: the length of the list at srclist after the operation.

Examples

redis> LPUSH mylist one
(integer) 1
redis> LPUSH mylist two
(integer) 2
redis> LPUSH mylist three
(integer) 3
redis> LXSPLICE mylist myotherlist -2 ATTACH 0 ORDER DESC
(integer) 1
redis> LRANGE mylist 0 -1
1) “three”
redis> LRANGE myotherlist 0 -1
1) “two”
2) “one”

© 2017 Redis Labs, Inc. All rights reserved.