@Test
public void testLettuce() throws InterruptedException {
    RedisClient redisClient = RedisClient.create("redis://zex1240888747@10.21.7.72:6379/0");
    StatefulRedisConnection<String, String> connection = redisClient.connect();
    RedisCommands<String, String> syncCommands = connection.sync();
    ThreadPoolExecutor t = (ThreadPoolExecutor)Executors.newFixedThreadPool(2);
    t.submit(()->{
       String key1result =  syncCommands.set("key1","111");
    });
    t.submit(()->{
        String key2result =  syncCommands.set("key2", "Hello, Redis!");
    });
    Thread.sleep(2000);
    connection.close();
    redisClient.shutdown();
}

看看我的代码,我启动两个线程发送redis命令与相同的连接,使用key1result和key2result接受结果 . 我们知道生菜可以通过一个tcp连接发送一次redis命令,但是如何恢复key1result和key2result对应的key1和key2返回值?