我目前已经在我的linux系统上测试了redis-benchmark,结果给我留下了深刻的印象。但在基准测试中,我使用了16个命令的流水线。现在我正试着在c#上执行它。我的主要问题是,我想要将数千个随机数据记录到redis中,而我不知道如何使用流水线。
提前谢谢。
发布于 2020-04-09 17:05:39
在StackExchange.Redis中使用流水线的最明确方式是使用CreateBatch应用编程接口:
var db = conn.GetDatabase();
var batch = db.CreateBatch();
// not shown: queue some async operations **without** awaiting them (yet)
batch.Execute(); // this sends the queued commands
// now await the things you queued但是,请注意,您可以在没有它的情况下实现很多目标,因为:
(使用批处理API确保批处理作为连续的块发送,而不是并发线程在批处理内交错工作;这与CreateTransaction()
还要注意,在一些批量场景中,您可能还需要考虑Lua (ScriptEvaluate());此API是可变的,因此可以适应任意的参数长度-您的Lua只需要检查KEYS和ARGV (discussed in the EVAL documentation)的大小。
https://stackoverflow.com/questions/61117360
复制相似问题