redis列表_Redis列表

redis列表

A list is a set of key-values pairs linked to each other.

列表是一组相互链接的键值对。

LPUSH and RPUSH are the two commands to work with lists.

LPUSHRPUSH是使用列表的两个命令。

You use the command LPUSH <listkey> <value> to create the first item.

您使用命令LPUSH <listkey> <value>创建第一项。

Example:

例:

LPUSH names "Flavio"

Then subsequent items can be added at the bottom of the list: RPUSH <listkey> <value>

然后可以将后续项添加到列表的底部: RPUSH <listkey> <value>

Or at the top of the list with LPUSH <listkey> <value>.

或在列表顶部使用LPUSH <listkey> <value>

Example:

例:

LPUSH names "Flavio"
LPUSH names "Syd"
RPUSH names "Roger"

You can add duplicate values into a list.

您可以将重复的值添加到列表中。

LPUSH names "Flavio"
LPUSH names "Flavio"
RPUSH names "Flavio"

A list can hold a big number of items, more than 4 billions.

列表可以容纳大量项目,超过40亿个。

Count how many items are in a list with LLEN <listkey>.

使用LLEN <listkey>列表中有多少项。

Get and remove the last item in a list with RPOP <listkey>. Do the same with the first item with LPOP.

使用RPOP <listkey>获取和删除列表中的最后一项。 使用LPOP对第一个项目执行相同的LPOP

Remove multiple items from the list using the LREM command.

使用LREM命令从列表中删除多个项目。

You can limit how long a list is using LTRIM.

您可以限制列表使用LTRIM

LTRIM names 0 1 cuts the list to just 2 items, item at position 0 (the first) and item at position 1.

LTRIM names 0 1将列表切为2个项目,位于位置0(第一个)的项目和位于位置1的项目。

Using LRANGE you can get the items in the list.

使用LRANGE您可以获得列表中的项目。

LRANGE names 0 100 returns items starting at position 0 (the beginning), ending at position 100.

LRANGE names 0 100返回从位置0(开始)开始,到位置100结束的项目。

LRANGE names 0 0 returns the item in position 0 (the first).

LRANGE names 0 0返回位置0(第一个)的项目。

LRANGE names 2 2 returns the item in position 2.

LRANGE names 2 2返回位置2的项目。

LRANGE names 0 -1 lists all items.

LRANGE names 0 -1列出所有项目。

See all the lists commands here.

在此处查看所有列表命令。

翻译自: https://flaviocopes.com/redis-lists/

redis列表

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值