【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>
Jedis所需要的jar包
- Commons-pool-1.6.jar
- Jedis-2.1.0.jar
用windows连接虚拟机的Redis的注意事项
- 禁用Linux的防火墙
- redis.conf中注释掉bind 127.0.0.1 ,然后 protect-mode no
Jedis测试连通性
/**
* @author Sun.Mr
* @create 2019-12-24 17:31
*/
public class Test {
public static void main(String[] args) {
Jedis jedis = new Jedis("47.105.154.78",6379);
String result =jedis.ping();
System.out.println(result);
}
}
测试部分API
public static void main(String[] args) {
Jedis jedis = new Jedis("47.105.154.78",6379);
String result =jedis.ping();
//keys (*)
Set<String> keys = jedis.keys("*");
for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
String key =(String)iterator.next();
System.out.println(key);
}
System.out.println("===============================");
System.out.println("jedis.exists====>"+jedis.exists("key1"));
System.out.println(jedis.ttl("key1"));
}
来源:oschina
链接:https://my.oschina.net/u/4152684/blog/3147014