Redis 1gt for list type operations; stack features: first-in-first-out, second-in-first-out 2gt; queue features: first-in-first-out, and then-out List is a linked list structure, which can be used as a stack
Redis 1gt for list type operations; stack features: first-in-first-out, second-in-first-out 2gt; queue features: first-in-first-out, and then-out List is a linked list structure, which can be used as a stack
Homepage → Database Technology
Background:
Read News
Redis list-type operations
[Date: 2013-11-15] Source: Linux Author: xiaohongyangok [Font:]
Redis list-type operations
1> stack features: first-in-first-out, and later-in-first-out
2> queue features: FIFO and FIFO
A List is a linked List structure that can be used as a stack or as a queue to process data.
Lpush mylist "world" // put world to the end of mylist
Lpush mylist "hello" // save hello to the end of mylist
Lrange 0-1 // obtain all elements in mylist
Rpush mylist2 "hello" // save hello to the mylist Header
Rpush mylist2 "world" // store the world to the mylist Header
Lrange 0-1
Linsert mylist2 before world "xhy" // Insert "xhy" to the front of the world element in mylist"
Lset mylist2 0 "example" // set the value of The 0th elements in mylist to "example"
Lpush mylist_rem "one"
Lpush mylist_rem "one"
Lpush mylist_rem "one"
Lrem mylist_rem 1 "one // delete one element with the value of" one"
Lpush mylist_ltrim "one"
Lpush mylist_ltrim "two"
Lpush mylist_ltrim "three"
Lpush mylist_ltrim "four"
Lpush mylist_ltrim "five"
Ltrim mylist_ltrim 2 3 // delete other elements except 2nd and 3rd
Lpush list_pop 1
Lpush list_pop 1
Lpush list_pop 1
Lrange list_pop 0-1
Lpop list_pop // Delete the first element of list_pop from the header
Rpop list_pop // Delete the first element of list_pop from the end
Lpush list_1 0
Lpush list_1 1
Lpush list_1 2
Lpush list_1 3
Lrange list_1 0-1
Lpush list_2 4
Lpush list_2 5
Lpush list_2 6
Lpush list_2 7
Lrange list_2 0-1
Rpoplpush list_1 list_2 // 1st elements are popped up from the end of list_1 and added to the header of list_2.
Lindex list_2 0 // retrieve 0th list_2 Elements
Lindex list_2 1
Llen // return the length of the linked list
Recommended reading:
Redis cluster details
Install Redis in Ubuntu 12.10 (graphic explanation) + Jedis to connect to Redis
Redis series-installation, deployment, and maintenance
Install Redis in CentOS 6.3
Redis. conf
Redis details: click here
Redis: click here
0
Redis operations on string and hash data
Use the Hibernate framework to insert Chinese characters in the MySQL database.
Related information Redis list operations
Image Information
View All comments in this article (0)
Comments
Latest Information
Popular this week
Introduction to Linux community-advertisement service-website map-help Info-contact us
The articles published on this site (LinuxIDC) do not mean that they agree with the statement or description. They only provide more information and do not constitute any suggestions.
Copyright©2006-2014 Linux community All rights reserved Zhejiang ICP backup No. 06018118