redis --- 集成lettuce

一、集成lettuce

1.1、导pom

 
            io.lettuce
            lettuce-core
            6.2.3.RELEASE
        
public class LettuceDemo {
    public static void main(String[] args) {
        //使用构建器链式编程来builder
        RedisURI uri = RedisURI.builder()
                .redis("192.168.200.170")
                .withPort(6380)
                .withAuthentication("default", "123456")
                .build();
        //创建客户端
        RedisClient redisClient = RedisClient.create(uri);
        StatefulRedisConnection connect = redisClient.connect();
        //创建操作的command
        RedisCommands commands = connect.sync();
        //操作redis
        commands.set("yyds","kkk");
        System.out.println(commands.get("yyds"));
        commands.keys("*");
        //关闭释放资源
        connect.close();
        redisClient.shutdown();
    }
}

你可能感兴趣的:(redis,redis)