hefeixia
2021-02-18 5b8c95c760840f09910730943b21391e47187315
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package chat.redis;
 
import redis.clients.jedis.Jedis;
 
public class RedisUtil {
 
    public static boolean createRedisKey(String key, String jsonStr) {
        boolean result = false;
        try {
             Jedis jedis = new Jedis("139.196.115.152");
             jedis.auth("uThyLr0gKTCf"); 
             if (jedis.exists(key))
                 jedis.del(key);
             jedis.set(key, jsonStr);
             jedis.expire(key, 2592000);
             jedis.close();
             result = true;
        } catch (Exception e) {
             result = false;
             e.printStackTrace();
        }
        return result;
    }
}