简体   繁体   English

Redis中的批量设置哈希

[英]Bulk setting hashes in Redis

I'm trying to store in Redis some entities which have an id and some properties: 我试图在Redis中存储一些具有ID和某些属性的实体:

id string(30)
firstname string(20)
lastname string(20)
bio string(150)

I've read in the docs that the best way to store this in Redis would be hashes. 我在文档中已经读到,将其存储在Redis中的最佳方法是散列。 is this correct? 这个对吗? I am receiving this entities in batches of 1000 and i would need to bulk store them in Redis, since doing it one by one, i assume would be very slow. 我要批量接收1000个实体,因此我需要将它们批量存储在Redis中,因为一个接一个地做,所以我认为这会很慢。 Is this possible? 这可能吗? Any better idea on how to store and import this? 关于如何存储和导入这个更好的主意吗?

Your assumption about doing it one by one will be slow is wrong. 您关于一步一步地做的假设很慢,这是错误的。 It will not be slow. 这不会慢。 Redis is very fast. Redis非常快。 You can get the idea from below benchmark:- 您可以从下面的基准中获得想法:-

./redis-benchmark -r 1000000 -n 2000000 -t get,set,lpush,lpop -P 16 -q
SET: 552028.75 requests per second
GET: 707463.75 requests per second
LPUSH: 767459.75 requests per second
LPOP: 770119.38 requests per second

More benchmark statistics:- 更多基准统计数据:

http://redis.io/topics/benchmarks http://redis.io/topics/benchmarks

As you mentioned entities are in the batch of 1000 which should not take more than few milliseconds. 正如您所提到的,实体在1000个批次中,不应超过几毫秒。 Just make sure you are using PIPELINE. 只要确保您正在使用PIPELINE。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM