redis - redis 的 LPUSH 列表操作接受的最大值是多少?

标签 redis

Redis 提供 LPUSH操作。

LPUSH key value [value ...]

单次操作最多支持多少个值?

最佳答案

关于此:http://redis.io/topics/data-types

The max length of a list is 2^32 - 1 elements (4294967295, more than 4 billion of elements per list).

我打赌你也可以一次使用这么多参数,但你可能会遇到客户端超时的情况。

当您的问题与性能有关时,我想这很适合阅读/了解。

更新

tias - bash 明文解析器

22:15 $ echo lpush works {1..1038} | redis-cli 
(integer) 1038
✔ ~ 
22:15 $ echo lpush worksnot {1..1039} | redis-cli 
(integer) 1038
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
(error) ERR unknown command '1039'
✔ ~ 
22:15 $ redis-cli 
127.0.0.1:6379> llen works
(integer) 1038
127.0.0.1:6379> llen worksnot
(integer) 1038
127.0.0.1:6379> llen worksnot

所以看起来限制是 1038。

lua 响应

> args = {'lpush', 'mylist'}
> for n = 1,100000 do
>> table.insert(args, tostring(n))
>> end
> 
> resp = require("resp")
> client = resp.new("127.0.0.1", 6379)
> client:call(unpack(args))
100000
> client:call('llen', 'mylist')
100000

100k 对 lua 没问题。 1m 太多了。 lua(不是 redis!)遇到 stdin:1: too many results to unpack 因为最大堆栈大小(猜测)。

我仍然敢打赌,您可以一次推送列表的最大长度……以防您的环境(编程语言、物理内存大小……)能够处理它。

关于redis - redis 的 LPUSH 列表操作接受的最大值是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35582647/

相关文章:

mysql - 为 EC2 上的高流量调整 php-fpm、nginx、mysql

ruby-on-rails - 如果从redis作业的渲染器中调用image_path返回错误的URL

Redis 无需迭代且无需弹出即可获取列表的所有值

amazon-web-services - AWS ElastiCache Redis - 一个可用区中的所有节点以避免数据传输成本

java - jar在catalina主页的lib文件夹中时,context.xml中类的ClassNotFoundException

caching - 堆叠缓存引擎

redis - 当您在特定数据库上运行 `KEYS` 命令时,Redis 会锁定所有可用数据库吗?

python - 使基于 SQL 的事件提要更快的好方法

redis - 将管道与 redis-cluster 一起使用时出现 Predis 错误

redis - SaltStack 作业检测