当前位置:网站首页>Redis list
Redis list
2022-07-06 01:40:00 【Freezing point contract】
Redis list (List)
Introduce
- Single bond multi value
- Redis List is a simple list of strings , Sort by insertion order . You can add an element to the head of the list ( On the left ) Or tail ( On the right )
- Its bottom layer is actually a two-way linked list , High performance on both ends , The performance of the nodes in the middle of the index subscript operation will be poor
Common commands
Insert one or more values from the left
lpush <key> <value1> <value2> ...
Insert one or more values from the right
rpush <key> <value1> <value2> ...
Pop up a value from the left ( The value will be deleted )
lpop <key>
Pop up a value from the right ( The value will be deleted )
rpop <key>
From the list key1 A value pops up on the right and is inserted into key2 On the left
rpoplpush <key1> <key2>
Get elements in batches according to the index (-1 Represents the last element )
lrange <key> <start> <stop>
Get a single element according to the index ( From left to right )
lindex <key> <index>
Get list length
llen <key>
stay value Insert element before target
linsert <key> before <value> <target>
Delete from the left n The values are value The elements of
lrem <key> <n> <value>
Index the list as index Replace the value of with value
lset <key> <index> <value>
The underlying data structure of the list
- List The data structure of is fast linked list quickList
- First, in the case of fewer list elements will use a block of continuous memory storage , This structure is ziplist, That is, compressed list ( It's like a sequence table ), It stores all the elements next to each other , Allocated is a continuous block of memory , When there is a large amount of data, it will be changed to quicklist, Because ordinary linked list needs too much additional pointer space , It's a waste of space . For example, what's in this list is just int Data of type , Two additional pointers are required for the structure prev and next
- Redis Linking lists and ziplist Combined to form quicklist, That is to say, multiple ziplist Use two-way pointer string to use . This not only satisfies the fast insertion and deletion performance , There will not be too much space redundancy
边栏推荐
猜你喜欢
Open source | Ctrip ticket BDD UI testing framework flybirds
C web page open WinForm exe
Selenium waiting mode
leetcode3、实现 strStr()
Poj2315 football games
National intangible cultural heritage inheritor HD Wang's shadow digital collection of "Four Beauties" made an amazing debut!
Loop structure of program (for loop)
Docker compose configures MySQL and realizes remote connection
You are using pip version 21.1.1; however, version 22.0.3 is available. You should consider upgradin
晶振是如何起振的?
随机推荐
Electrical data | IEEE118 (including wind and solar energy)
MATLB | real time opportunity constrained decision making and its application in power system
c#网页打开winform exe
Redis守护进程无法停止解决方案
False breakthroughs in the trend of London Silver
MUX VLAN configuration
selenium 元素定位(2)
Threedposetracker project resolution
Spir - V premier aperçu
National intangible cultural heritage inheritor HD Wang's shadow digital collection of "Four Beauties" made an amazing debut!
[Jiudu OJ 09] two points to find student information
Kubernetes stateless application expansion and contraction capacity
【网络攻防实训习题】
037 PHP login, registration, message, personal Center Design
Internship: unfamiliar annotations involved in the project code and their functions
3D vision - 4 Getting started with gesture recognition - using mediapipe includes single frame and real time video
[ssrf-01] principle and utilization examples of server-side Request Forgery vulnerability
Basic operations of databases and tables ----- primary key constraints
【Flask】官方教程(Tutorial)-part2:蓝图-视图、模板、静态文件
NumPy 数组索引 切片