/**
* 使用RedisTemplate 流水线
*/
@Test
public void testPipelineBySpring() {
SessionCallback callback = (SessionCallback)(RedisOperations ops)->{
for(int i = 0; i < 100000; i++) {
int j = i + 1;
ops.boundValueOps(“key” + j).set(“value” + j);
ops.boundValueOps(“key” + j).get();
}
return null;
};
long start = System.currentTimeMillis();
// 执行Redis的流水线命令
List result = redisTemplate.executePipelined(callback);
long end = System.currentTimeMillis();
System.out.println(end - start);
}
RedisTemplate 流水线
最新推荐文章于 2024-04-25 16:56:43 发布