Redis database of 03_NoSQL Database: list type, 03_nosqlredis

Source: Internet
Author: User

Redis database of 03_NoSQL Database: list type, 03_nosqlredis
Zookeeper

Lists type and Operation

List is a linked List structure. The main function room is push, pop, get all values in a range, etc. In the operation, the key is interpreted as the name of the linked List. The list type of Redis is actually a two-way linked list with every element of the string type. We can add and delete elements from the head or tail of the linked list through the push and pop operations, so that the list can be both a stack and a queue.

Lpush: Add a string element to the header of the list corresponding to the key.

 

Rpush: Add a string element at the end of the list corresponding to the key.

Linsert: Add a string before or after a specific position of the key corresponding to the list.

 

Lset: set the value of the element specified in the list object.

Lrem: deletes n elements with the same value from the list corresponding to the key. (N <0 is deleted from the end, n = 0 is all deleted)

The above lrem mylist5 1 "hello" indicates that the same value as hello is deleted from mylist5.

The number returned above indicates the number of deletions.

 

Ltrim: retains data within the value range of the specified key.

For example, ltrim list8 1-1 indicates that the value of the subscript from 1 to the last element is retained, and all other elements are deleted.

 

Lpop: deletes an element from the list header and returns the deletion element.

 

Rpop list10

Lrange list10 0-1

 

Rpoplpush: Removes elements from the end of the first list and adds them to the header of the second list.

Rpoplpush mylist5 mylist6 indicates that the elements in mylist5 are popped up and sent to mylist6.

Check mylist5 and find that there is only one three. Then, check mylist6 and find that there are three elements: hello, hello, foo.

 

Lindex: returns the index position element in the list named key.

 

Llen: view the number of elements in the linked list

 

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.