一、新建Maven项目
二、导入Jedis依赖
<dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>3.2.0</version> </dependency>
三、获取连接-创建Jedis对象
四、测试操作
五、关闭连接
//创建Jedis对象 Jedis jedis = new Jedis("192.168.189.128", 6379); //测试 String value = jedis.ping(); System.out.println(value); jedis.set("k1", "v1"); jedis.set("k2", "v2"); jedis.set("k3", "v3"); Set<String> keys = jedis.keys("*"); System.out.println(keys.size()); for(String key : keys){ System.out.println(key); } System.out.println(jedis.exists("k1")); //关闭连接 jedis.close();
标签:keys,System,jedis,println,Jedis,out From: https://www.cnblogs.com/fxzm/p/17452330.html