当前位置:网站首页>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使用双向指针串起来使用。这样既满足了快速的插入删除性能,又不会出现太大的空间冗余
边栏推荐
- Test de vulnérabilité de téléchargement de fichiers basé sur dvwa
- Paging of a scratch (page turning processing)
- 【全网最全】 |MySQL EXPLAIN 完全解读
- A glimpse of spir-v
- leetcode刷题_反转字符串中的元音字母
- Redis' cache penetration, cache breakdown, cache avalanche
- 黄金价格走势k线图如何看?
- Une image! Pourquoi l'école t'a - t - elle appris à coder, mais pourquoi pas...
- 什么是弱引用?es6中有哪些弱引用数据类型?js中的弱引用是什么?
- Internship: unfamiliar annotations involved in the project code and their functions
猜你喜欢

【Flask】官方教程(Tutorial)-part1:项目布局、应用程序设置、定义和访问数据库

Docker compose configures MySQL and realizes remote connection
![[pat (basic level) practice] - [simple mathematics] 1062 simplest fraction](/img/b4/3d46a33fa780e5fb32bbfe5ab26a7f.jpg)
[pat (basic level) practice] - [simple mathematics] 1062 simplest fraction

【SSRF-01】服务器端请求伪造漏洞原理及利用实例
![[机缘参悟-39]:鬼谷子-第五飞箝篇 - 警示之二:赞美的六种类型,谨防享受赞美快感如同鱼儿享受诱饵。](/img/3c/ec97abfabecb3f0c821beb6cfe2983.jpg)
[机缘参悟-39]:鬼谷子-第五飞箝篇 - 警示之二:赞美的六种类型,谨防享受赞美快感如同鱼儿享受诱饵。

Recommended areas - ways to explore users' future interests

MATLB | real time opportunity constrained decision making and its application in power system

基于DVWA的文件上传漏洞测试

【Flask】官方教程(Tutorial)-part2:蓝图-视图、模板、静态文件

Basic operations of databases and tables ----- default constraints
随机推荐
SPIR-V初窥
基於DVWA的文件上傳漏洞測試
500 lines of code to understand the principle of mecached cache client driver
Poj2315 football games
ClickOnce does not support request execution level 'requireAdministrator'
Spir - V premier aperçu
【Flask】官方教程(Tutorial)-part1:项目布局、应用程序设置、定义和访问数据库
Three methods of script about login and cookies
Some features of ECMAScript
How does the crystal oscillator vibrate?
Unity VR solves the problem that the handle ray keeps flashing after touching the button of the UI
Basic operations of databases and tables ----- unique constraints
How does Huawei enable debug and how to make an image port
Modify the ssh server access port number
Leetcode skimming questions_ Sum of squares
有谁知道 达梦数据库表的列的数据类型 精度怎么修改呀
About error 2003 (HY000): can't connect to MySQL server on 'localhost' (10061)
【已解决】如何生成漂亮的静态文档说明页
Unity VR resource flash surface in scene
Basic operations of databases and tables ----- primary key constraints