我正在使用 jedis 管道将一批数据插入到 redis 中。现在我面临一个困惑的问题。我想批量处理一个特定的大小,然后调用sync(),但似乎管道大约每200条记录会自动调用一次同步。这是我的代码,谁能告诉我是否存在任何配置?
public class RedisClusterTest {
public static void main(String args[]) throws IOException, InterruptedException {
String host = args[0];
int port = Integer.valueOf(args[1]);
int cnt = Integer.valueOf(args[2]);
Jedis jedis = new Jedis(host, port);
Pipeline pip = jedis.pipelined();
for(int i = 0 ; i < 2000; i++) {
pip.hset("Server", String.valueOf(i), String.valueOf(i));
Thread.sleep(10);
}
// When it end loop, about 1900 records has already been insert into redis, and the last sync only made last remaining data been sync.
pip.sync()
吃鸡游戏
相关分类