Redis QuickStart-Redis list (10)

Source: Internet
Author: User

The Reids list is a simple list of strings, sorted in order of insertion. You can add elements to the list at the end of the head or list of Redis.

Example

Redis 127.0.0.1:6379> Lpush Tutorials Redis

(integer) 1

Redis 127.0.0.1:6379> Lpush Tutorials MongoDB

(integer) 2

Redis 127.0.0.1:6379> Lpush Tutorials MySQL

(integer) 3

Redis 127.0.0.1:6379> Lrange Tutorials 0 10

1) "MySQL"

2) "MongoDB"

3) "Redis"

In the above example, the three values are inserted into the Redis list named tutorials using the Lpush command.

Reids List of commands

Some basic commands are listed as shown in the following table:

S.N. Command & Description
1

Blpop key1 [Key2] Timeout

Remove and get the first element in the list, or block until there is an available

2

Brpop key1 [Key2] Timeout

Remove and get the last element in the list, or block until there are available

3

Brpoplpush Source Destination Timeout

POPs a value from the list, pushes it to another list and returns it, or blocks until there are available

4

LINDEX Key Index

Get the corresponding element from a list with its index

5

Linsert Key before| After pivot value

Insert an element after or before another element in the list

6

Llen Key

Get the length of a list

7

Lpop Key

Gets and removes the first element in a list

8

Lpush key value1 [value2]

Add a list of one or more values in front

9

Lpushx Key value

Precede with a list of values, only if the list exists

10

Lrange Key Start stop

Get various elements from a list

11

Lrem Key Count value

Remove an element from the list

12

LSET Key index value

Set the value of an element in the index in the list

13

LTRIM Key Start stop

Trim list to specified range

14 Rpop key removes and gets the last element in the list
15

Rpuplpush Source Destination

Removes the list of the last element, attaches it to 21 lists, and returns it

16

Rpush key value1 [value2]

Add one or more values to the list

17

Rpushx Key value

Add a list of values only if the list exists

Redis QuickStart-Redis list (10)

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.