当前位置:网站首页>Redis-列表
Redis-列表
2022-07-06 01:29:00 【冰点契约丶】
Redis列表(List)
介绍
- 单键多值
- Redis 列表是简单的字符串列表,按照插入顺序排序。你可以添加一个元素到列表的头部(左边)或者尾部(右边)
- 它的底层实际是个双向链表,对两端的操作性能很高,通过索引下标的操作中间的节点性能会较差
常用命令
从左边插入一个或多个值
lpush <key> <value1> <value2> ...从右边插入一个或多个值
rpush <key> <value1> <value2> ...从左边弹出一个值(值会被删除)
lpop <key>从右边弹出一个值(值会被删除)
rpop <key>从列表key1右边弹出一个值插入到key2左边
rpoplpush <key1> <key2>根据索引批量获取元素(-1代表最后一个元素)
lrange <key> <start> <stop>根据索引获取单个元素(从左到右)
lindex <key> <index>获取列表长度
llen <key>在value之前插入元素target
linsert <key> before <value> <target>从左边删除n个值为value的元素
lrem <key> <n> <value>将列表中索引为index的值替换为value
lset <key> <index> <value>
列表的底层数据结构

- List的数据结构为快速链表quickList
- 首先在列表元素较少的情况下会使用一块连续的内存存储,这个结构是ziplist,也即是压缩列表(类似于顺序表),它将所有的元素紧挨着一起存储,分配的是一块连续的内存,当数据量比较多的时候才会改成quicklist,因为普通的链表需要的附加指针空间太大,会比较浪费空间。比如这个列表里存的只是int类型的数据,结构上还需要两个额外的指针prev和next
- Redis将链表和ziplist结合起来组成了quicklist,也就是将多个ziplist使用双向指针串起来使用。这样既满足了快速的插入删除性能,又不会出现太大的空间冗余
边栏推荐
- [机缘参悟-39]:鬼谷子-第五飞箝篇 - 警示之二:赞美的六种类型,谨防享受赞美快感如同鱼儿享受诱饵。
- General operation method of spot Silver
- Netease smart enterprises enter the market against the trend, and there is a new possibility for game industrialization
- Unity | 实现面部驱动的两种方式
- 晶振是如何起振的?
- c#网页打开winform exe
- Force buckle 1020 Number of enclaves
- C web page open WinForm exe
- 网易智企逆势进场,游戏工业化有了新可能
- [technology development -28]: overview of information and communication network, new technology forms, high-quality development of information and communication industry
猜你喜欢

General operation method of spot Silver

Une image! Pourquoi l'école t'a - t - elle appris à coder, mais pourquoi pas...

Leetcode skimming questions_ Verify palindrome string II

Unity | 实现面部驱动的两种方式
![[flask] official tutorial -part3: blog blueprint, project installability](/img/fd/fc922b41316338943067469db958e2.png)
[flask] official tutorial -part3: blog blueprint, project installability

leetcode刷题_反转字符串中的元音字母

Basic operations of databases and tables ----- primary key constraints

基於DVWA的文件上傳漏洞測試

Force buckle 1020 Number of enclaves

Cookie concept, basic use, principle, details and Chinese transmission
随机推荐
Three methods of script about login and cookies
Recommended areas - ways to explore users' future interests
VMware Tools installation error: unable to automatically install vsock driver
【Flask】响应、session与Message Flashing
Electrical data | IEEE118 (including wind and solar energy)
[technology development -28]: overview of information and communication network, new technology forms, high-quality development of information and communication industry
How to extract MP3 audio from MP4 video files?
Hcip---ipv6 experiment
Yii console method call, Yii console scheduled task
WGet: command line download tool
LeetCode 322. Change exchange (dynamic planning)
Leetcode 剑指 Offer 59 - II. 队列的最大值
Blue Bridge Cup embedded stm32g431 - the real topic and code of the eighth provincial competition
有谁知道 达梦数据库表的列的数据类型 精度怎么修改呀
Leetcode sword finger offer 59 - ii Maximum value of queue
How does Huawei enable debug and how to make an image port
leetcode刷题_反转字符串中的元音字母
UE4 unreal engine, editor basic application, usage skills (IV)
Spir - V premier aperçu
Code Review关注点