import io.lettuce.core.RedisClient; import io.lettuce.core.api.StatefulRedisConnection; import io.lettuce.core.api.sync.RedisCommands; public class LettuceExample { public static void main(String[] args) { RedisClient redisClient = RedisClient.create("redis://localhost:6379"); StatefulRedisConnection<String, String> connection = redisClient.connect(); RedisCommands<String, String> syncCommands = connection.sync(); syncCommands.set("key", "value"); String value = syncCommands.get("key"); System.out.println(value); connection.close(); redisClient.shutdown(); } } import io.lettuce.core.RedisClient; import io.lettuce.core.api.StatefulRedisConnection; import io.lettuce.core.api.sync.RedisCommands; public class LettuceExample { public static void main(String[] args) { RedisClient redisClient = RedisClient.create("redis://localhost:6379"); StatefulRedisConnection<String, String> connection = redisClient.connect(); RedisCommands<String, String> syncCommands = connection.sync(); syncCommands.set("key", "value"); String value = syncCommands.get("key"); System.out.println(value); connection.close(); redisClient.shutdown(); } } <dependency> <groupId>io.lettuce</groupId> <artifactId>lettuce-core</artifactId> <version>5.3.2.RELEASE</version> </dependency> shell bind 127.0.0.1 port 6379


上一篇:
下一篇:
切换中文