See also
The Python-side representaion of Redis list value. It behaves alike built-in Python list object. More exactly, it implements collections.MutableSequence protocol.
Redis commands | List methods |
---|---|
LLEN | len() (List.__len__()) |
LPUSH | List.insert() |
LPUSHX | N/A |
LPOP | List.pop() |
RPUSH | List.append(), List.extend() |
RPUSHX | N/A |
RPOP | List.pop() |
RPOPLPUSH | N/A |
LINDEX | List.__getitem__(), |
LINSERT | N/A |
LRANGE | iter() (List.__iter__()), List.__getitem__(), |
LREM | N/A |
LTRIM | del (List.__delitem__()) |
DEL | del (List.__delitem__()) |
LSET | = (List.__setitem__()) |
BLPOP | N/A |
BRPOP | N/A |
BRPOPLPUSH | N/A |
Inserts the value at the tail of the list.
Parameters: | value – an value to insert |
---|
Extends the list with the iterable.
Parameters: | iterable (collections.Iterable) – an iterable object that extend the list with |
---|---|
Raises exceptions.TypeError: | |
if the given iterable is not iterable |
Warning
Appending multiple values is supported since Redis 2.4.0. This may send RPUSH multiple times in a transaction if Redis version is not 2.4.0 nor higher.
Inserts the value right after the offset index.
Parameters: |
|
---|---|
Raises exceptions.TypeError: | |
if the given index is not an integer |
Warning
Redis does not provide any primitive operations for random insertion. You only can prepend or append a value into lists. If index is 0 it’ll send LPUSH command, but otherwise it inefficiently LRANGE the whole list to manipulate it in offline, and then DEL the key so that empty the whole list, and then RPUSH the whole result again. Moreover all the commands execute in a transaction.
So you should not treat this method as the same method of Python built-in list object. It is just for being compatible to collections.MutableSequence protocol.
If it faced the case, it also will warn you PerformanceWarning.
Removes and returns an item at index. Negative index means len(list) + index (counts from the last).
Parameters: |
|
---|---|
Returns: | the removed element |
Raises: |
|
Warning
Redis doesn’t offer any primitive operations for random deletion. You can pop only the last or the first. Other middle elements cannot be popped in a command, so it emulates the operation inefficiently.
Internal emulation routine to pop an other index than -1 or 0 consists of three commands in a transaction:
So you should not treat this method as the same method of Python built-in list object. It is just for being compatible to collections.MutableSequence protocol.
If it faced the case, it also will warn you PerformanceWarning.
(sider.types.Bulk) The type of list values.