package com.example.sso.util; import redis.clients.jedis.Jedis; public class JedisUtil { private static final String HOST = "154.8.146.52"; private static final int PORT = 6379; // 获取Jedis连接 public static Jedis getJedisClient() { return new Jedis(HOST, PORT); } // 设置键值对 public static void set(String key, String value) { try (Jedis jedis = getJedisClient()) { jedis.set(key, value); } } // 获取值 public static String get(String key) { try (Jedis jedis = getJedisClient()) { return jedis.get(key); } } // 删除键 public static void del(String key) { try (Jedis jedis = getJedisClient()) { jedis.del(key); } } // 设置过期时间 public static void expire(String key, int seconds) { try (Jedis jedis = getJedisClient()) { jedis.expire(key, seconds); } } }