【依赖】
<dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.9.0</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.3.2</version> </dependency>
【imports】
import redis.clients.jedis.Jedis;
【代码】
Jedis jedis = new Jedis("192.168.32.128"); System.out.println("连接成功"); jedis.set("ufo", "www.ufo.com"); System.out.println("redis 存储的字符串为: "+ jedis.get("ufo"));
输出:
连接成功
redis 存储的字符串为: www.ufo.com
END