Java对redis链接操做

一、maven项目中直接引入Jedis包,非maven项目能够下载相关的jar包java

<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.6.1</version>
</dependency>

二、链接redisredis

//链接本地redis服务,默认端口号6379
Jedis jedis = new Jedis("localhost");

//链接redis服务
//Jedis jedis = new Jedis("服务地址","端口号");
System.out.println("Connection to server sucessfully");


//查看服务是否运行
System.out.println("Server is running: " + jedis.ping());
相关文章
相关标签/搜索