1、导入依赖:
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
2、连接JDBC
public class JedisDemo05 {
public static void main(String[] args) {
Jedis jedis = new Jedis("192.168.226.100", 7000);
String name = jedis.set("name", "tom");
System.out.println(name);
String s = jedis.get("name");
String mset = jedis.mset("age","18","age1","19");
List mget = jedis.mget("age", "age1");
System.out.println(mget);
long clazz = jedis.lpush("clazz", "clazz1", "clazz2", "clazz3");
List clazz1 = jedis.lrange("clazz", 0, -1);
System.out.println(clazz1);
long sadd = jedis.sadd("gender", "男");
Set gender = jedis.smembers("gender");
System.out.println(gender);
long zadd = jedis.zadd("score", 90, "math");
Double zscore = jedis.zscore("score", "math");
System.out.println(zscore);
HashMap map = new HashMap<>();
long hset = jedis.hset("个人信息", map);
Map hgetAll = jedis.hgetAll("个人信息");
System.out.println(hgetAll);