List list
Redis list is a simple list of strings, sort insertion order. You can add a head guide elements of the list (on the left) or tails (to the right)
The basic command list list--
lpush
语法:lpush key value [value„]
Action: one or more values of key value inserted into the list header (far left), the value added from the left, left to right are sequentially inserted into the header
Return Value: length of the digital, the new list
Rpus
语法:rpush key value [value„]
Action: one or more values of the key value is inserted into the tail of the list (far right), the value of the respective value from left to right are sequentially inserted into the end of the table
Return Value: length of the digital, the new list
lrange
Syntax: lrange key start stop
Action: Get a list of key elements within the specified range, 0 represents the first element of the list, in a list indicating the second element;
start, stop value is the index of the list, the index may be negative, a -1 is the last element of the list, -2 represent the penultimate element of the list, and so on.
start, stop beyond the scope of the list of error does not occur.
Returns: a list of the designated section
lindex
Syntax: lindex key index
Role: Get a list of the key index for the specified index of elements, list elements are not deleted, only the query.
0 indicates the first element in the list to represent a second element of the list;
start, stop value is the index of the list, the index may be negative, a -1 is the last element of the list, -2 represent the penultimate element of the list, and so on.
Return Value: the specified index element; index range not in the list, returns nil
len
Syntax: llen key
Action: Get a list of key length Return Value: value, the length of the list; absent key returns 0
lrem
Syntax: lrem key count value
Action: The count value of the parameter, the removal of the list elements is equal to the parameter value,
count> 0, is removed from the list on the left to the right start of;
count <0 start removed from the end of the list;
all count = 0 value equal to the value in the table is removed.
The number of values, elements to be removed: Return value
lset
Syntax: lset key index value
Action: The key index list set index value of the element is to value.
Return Value: returns the set successfully ok; key is not present or returns an error index is out of range
linsert
Syntax: linsert key BEFORE (before) | AFTER (after) pivot value
effect:
The value of the value list before the key is inserted to a position which is located in or after the pivot value.
key does not exist, pivot not on the list, do not do anything.
Returns: the command is successful, returns the length of the new list. Did not find the pivot return -1, key does not exist return 0.
RPOP key
Removes the last element of the list, the return value of the element removed.
RPOPLPUSH source destination
Removes the last element of the list, and adds the element to another list and return
LPOP key
Removes the first element of the list, the return element is removed.