Returns an element from a list by its index.
Returns an element from a list by its index.
list key
zero-based position in the list
the requested element, or None
when index is out of range
1.0.0
[[scredis.exceptions.RedisErrorResponseException]]
if key contains a non-list value
The index is zero-based, so 0 means the first element, 1 the second element and so on. Negative indices can be used to designate elements starting at the tail of the list. Here, -1 means the last element, -2 means the penultimate and so forth.
Inserts an element before or after another element in a list.
Inserts an element before or after another element in a list.
list key
value after/before which the element should be inserted
element to be inserted
the length of the list after the insert operation, or None if the index is out of range
2.2.0
[[scredis.exceptions.RedisErrorResponseException]]
if key contains a non-list value
Returns the length of a list.
Returns the length of a list.
list key
the length of the list at key, or 0 if the key does not exist
1.0.0
[[scredis.exceptions.RedisErrorResponseException]]
if key contains a non-list value
Removes and returns the first element of a list.
Removes and returns the first element of a list.
list key
the popped element, or None
if the key does not exist
1.0.0
[[scredis.exceptions.RedisErrorResponseException]]
if key contains a non-list value
Prepends one or multiple values to a list.
Prepends one or multiple values to a list.
list key
value(s) to prepend
the length of the list after the push operations
1.0.0
[[scredis.exceptions.RedisErrorResponseException]]
if key contains a non-list value
If key does not exist, it is created as empty list before performing the push operation. Redis versions older than 2.4 can only push one value per call.
Prepends a value to a list, only if the list exists.
Prepends a value to a list, only if the list exists.
list key
value to prepend
the length of the list after the push operation
2.2.0
[[scredis.exceptions.RedisErrorResponseException]]
if key contains a non-list value
Returns a range of elements from a list.
Returns a range of elements from a list.
list key
start offset (inclusive)
stop offset (inclusive)
list of elements in the specified range, or the empty list if there are no such elements or the key does not exist
1.0.0
[[scredis.exceptions.RedisErrorResponseException]]
if key contains a non-list value
The offsets start and end are zero-based indexes, with 0 being the first element of the list (the head of the list), 1 being the next element and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list. For example, -1 is the last element of the list, -2 the penultimate, and so on. Both offsets are inclusive, i.e. LRANGE key 0 10 will return 11 elements (if they exist).
Removes the first count occurrences of elements equal to value from the list stored at key.
Removes the first count occurrences of elements equal to value from the list stored at key.
list key
value to be removed from the list
indicates the number of found values that should be removed, see above note
the number of removed elements
1.0.0
[[scredis.exceptions.RedisErrorResponseException]]
if key contains a non-list value
The count argument influences the operation in the following ways:
count > 0: Remove elements equal to value moving from head to tail. count < 0: Remove elements equal to value moving from tail to head. count = 0: Remove all elements equal to value.
Sets the value of an element in a list by its index.
Sets the value of an element in a list by its index.
list key
position of the element to set
value to be set at index
1.0.0
[[scredis.exceptions.RedisErrorResponseException]]
if index is out of range or if key contains a non-list value
Trims a list to the specified range.
Trims a list to the specified range.
list key
start offset (inclusive)
stop offset (inclusive)
1.0.0
[[scredis.exceptions.RedisErrorResponseException]]
if key contains a non-list value
Out of range indexes will not produce an error: if start is larger than the end of the list, or start > end, the result will be an empty list (which causes key to be removed). If end is larger than the end of the list, Redis will treat it like the last element of the list.
Removes and returns the last element of a list.
Removes and returns the last element of a list.
list key
the popped element, or None
if the key does not exist
1.0.0
[[scredis.exceptions.RedisErrorResponseException]]
if key contains a non-list value
Removes the last element in a list, appends it to another list and returns it.
Removes the last element in a list, appends it to another list and returns it.
key of list to be pop from
key of list to be push to
the popped element, or None
if the key does not exist
1.2.0
[[scredis.exceptions.RedisErrorResponseException]]
if key contains a non-list value
Appends one or multiple values to a list.
Appends one or multiple values to a list.
list key
value(s) to prepend
the length of the list after the push operations
1.0.0
[[scredis.exceptions.RedisErrorResponseException]]
if key contains a non-list value
If key does not exist, it is created as empty list before performing the push operation. Redis versions older than 2.4 can only push one value per call.
Appends a value to a list, only if the list exists.
Appends a value to a list, only if the list exists.
list key
value to prepend
the length of the list after the push operation
2.2.0
[[scredis.exceptions.RedisErrorResponseException]]
if key contains a non-list value
This trait implements list commands.