rpoplpush method

Future<String?> rpoplpush(
  1. String source,
  2. String destination
)

Atomically returns and removes the last element (tail) of the list stored at source, and pushes the element at the first element (head) of the list stored at destination.

For example: consider source holding the list a,b,c, and destination holding the list x,y,z. Executing RPOPLPUSH results in source holding a,b and destination holding c,x,y,z.

If source does not exist, the value nil is returned and no operation is performed. If source and destination are the same, the operation is equivalent to removing the last element from the list and pushing it as first element of the list, so it can be considered as a list rotation command.

Returns the element being popped and pushed.

Implementation

Future<String?> rpoplpush(String source, String destination) async {
  return (await tier1.rpoplpush(source, destination)).toBulkString().payload;
}