Redis客户端之Lettuce

简介:基于Netty框架的事件驱动的通信层,Redis 客户端,线程安全同步。异步调用。

lettuce 官网地址:https://lettuce.io/

lettuce git项目地址:https://github.com/lettuce-io/lettuce-core

使用:
1、在pom.xml 中加入依赖

io.lettuce lettuce-core 5.1.7.RELEASE

2、 调用

import io.lettuce.core.*;

RedisClient redisClient = RedisClient.create("redis://password@localhost:6379/0");
StatefulRedisConnection<String, String> connection = redisClient.connect();
RedisCommands<String, String> syncCommands = connection.sync();

syncCommands.set("key", "Hello, Redis!");

connection.close();
redisClient.shutdown();

posted @ 2019-07-16 09:09  北方有鱼  阅读(3042)  评论(0编辑  收藏  举报