当前位置:网站首页>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
边栏推荐
- Mongodb problem set
- leetcode刷题_反转字符串中的元音字母
- 【SSRF-01】服务器端请求伪造漏洞原理及利用实例
- Flutter Doctor:Xcode 安装不完整
- 【全網最全】 |MySQL EXPLAIN 完全解讀
- Dynamics 365 开发协作最佳实践思考
- Alibaba canal usage details (pit draining version)_ MySQL and ES data synchronization
- 【Flask】官方教程(Tutorial)-part3:blog蓝图、项目可安装化
- Basic operations of databases and tables ----- unique constraints
- Basic operations of databases and tables ----- primary key constraints
猜你喜欢
How to see the K-line chart of gold price trend?
Basic process and testing idea of interface automation
Cookie concept, basic use, principle, details and Chinese transmission
A picture to understand! Why did the school teach you coding but still not
Huawei Hrbrid interface and VLAN division based on IP
NLP fourth paradigm: overview of prompt [pre train, prompt, predict] [Liu Pengfei]
【已解决】如何生成漂亮的静态文档说明页
Leetcode3. Implement strstr()
Superfluid_ HQ hacked analysis
MUX VLAN configuration
随机推荐
MATLB|实时机会约束决策及其在电力系统中的应用
How to get the PHP version- How to get the PHP Version?
【Flask】官方教程(Tutorial)-part1:项目布局、应用程序设置、定义和访问数据库
[flask] official tutorial -part1: project layout, application settings, definition and database access
A picture to understand! Why did the school teach you coding but still not
Leetcode skimming questions_ Verify palindrome string II
LeetCode 322. Change exchange (dynamic planning)
Threedposetracker project resolution
普通人下场全球贸易,新一轮结构性机会浮出水面
什么是弱引用?es6中有哪些弱引用数据类型?js中的弱引用是什么?
module ‘tensorflow. contrib. data‘ has no attribute ‘dataset
Selenium waiting mode
Leetcode3. Implement strstr()
竞赛题 2022-6-26
一圖看懂!為什麼學校教了你Coding但還是不會的原因...
2022年广西自治区中职组“网络空间安全”赛题及赛题解析(超详细)
National intangible cultural heritage inheritor HD Wang's shadow digital collection of "Four Beauties" made an amazing debut!
How to see the K-line chart of gold price trend?
Basic operations of database and table ----- delete data table
Kubernetes stateless application expansion and contraction capacity