LettuceRedis 的 Java 客户端开发包
Lettuce是一个可伸缩线程安全的Redis客户端。多个线程可以共享同一个RedisConnection。它利用优秀netty NIO框架来高效地管理多个连接。
示例代码:
RedisClient client = new RedisClient("localhost") RedisConnection<String, String> connection = client.connect() String value = connection.get("key")
异步 API
StatefulRedisConnection<String, String> connection = client.connect(); RedisStringAsyncCommands<String, String> async = connection.async(); RedisFuture<String> set = async.set("key", "value") RedisFuture<String> get = async.get("key") async.awaitAll(set, get) == true set.get() == "OK" get.get() == "value"
评论