Redis List command

Source: Internet
Author: User
Tags key string

?

?

Command

Explain

lpush key string

in the key corresponding to the list's header Add string element, return 1 for success, 0 means that key exists and is not a list type.

rpush key string

Ibid., end insert.

llen key

Returns the length of the key corresponding to the list, key does not exist return 0 if the key corresponding type is not a list return error.

lrange key start end

Returns the element within the specified interval, the subscript starts at 0, the negative value is calculated from the back, 1 is the first element of the countdown, Key does not exist returns an empty list.

LTrim key start end

intercept list, keep elements within specified interval, successfully return 1,key there is no return error.

lset key index value

Sets the value of the element specified in the list, returns 1,key successfully or the subscript does not have a return error.

lrem key count value

lpop key

rpop key

Ibid. Tail delete.

blpop Key1...keyn Timeout

left-to-right scan returns a LPOP operation on the first non-empty list and returns, such as Blpop List1 List2 List3 0, if the list does not exist, LIST2,LIST3 is non-null to List2 Lpop and returns the element removed from the List2. If all the lists are empty or nonexistent, the timeout second is blocked, and a timeout of 0 means that it is blocked.

brpop

with Blpop, one to remove from the head is to remove from the tail

rpoplpush Srckey Destkey

Remove the element from the tail of the Srckey corresponding list and add it to the header of the destkey corresponding list. Finally, the value of the removed element is returned, and the entire operation is atomic. If Srckey is empty

LINDEX key index

Returns the element in the list key labeled Index.

You can also use a negative subscript, 1 for the last element of the list, 2 for the penultimate element of the list, and so on.

Linsert Key before| After pivot value

Inserts a value in the list key, either before or after the value pivot.

When pivot does not exist in the list key, no action is taken.

When key does not exist, key is treated as an empty list, and no action is taken.

If key is not a list type, an error is returned.

Redis List command

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.