Spermatid v6.1.8版本的 MD5 值为:a375ce51a42d528ba6e2583c10478296

以下内容为反编译后的 RedisDS.java 源代码,内容仅作参考


package cn.hutool.db.nosql.redis;

import a1.d;
import cn.hutool.core.io.b;
import cn.hutool.setting.Setting;
import java.io.Closeable;
import java.io.Serializable;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLParameters;
import javax.net.ssl.SSLSocketFactory;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class RedisDS implements Closeable, Serializable {
    public static final String REDIS_CONFIG_PATH = "config/redis.setting";
    private static final long serialVersionUID = -5605411972456177456L;
    private JedisPool pool;
    private Setting setting;

    public RedisDS() {
        this(null, null);
    }

    public static RedisDS create() {
        return new RedisDS();
    }

    @Override
    public void close() {
        b.b(this.pool);
    }

    public Long del(String... strArr) {
        Jedis jedis = getJedis();
        try {
            long del = jedis.del(strArr);
            jedis.close();
            return Long.valueOf(del);
        } catch (Throwable th) {
            try {
                throw th;
            } catch (Throwable th2) {
                if (jedis != null) {
                    try {
                        jedis.close();
                    } catch (Throwable th3) {
                        th.addSuppressed(th3);
                    }
                }
                throw th2;
            }
        }
    }

    public Jedis getJedis() {
        return this.pool.getResource();
    }

    public String getStr(String str) {
        Jedis jedis = getJedis();
        try {
            String str2 = jedis.get(str);
            jedis.close();
            return str2;
        } catch (Throwable th) {
            try {
                throw th;
            } catch (Throwable th2) {
                if (jedis != null) {
                    try {
                        jedis.close();
                    } catch (Throwable th3) {
                        th.addSuppressed(th3);
                    }
                }
                throw th2;
            }
        }
    }

    public RedisDS init(String str) {
        if (this.setting == null) {
            this.setting = new Setting(REDIS_CONFIG_PATH, true);
        }
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        this.setting.toBean((Setting) jedisPoolConfig);
        if (d.M(str)) {
            this.setting.toBean(str, (String) jedisPoolConfig);
        }
        Long l10 = this.setting.getLong("maxWaitMillis");
        if (l10 != null) {
            jedisPoolConfig.setMaxWaitMillis(l10.longValue());
        }
        String str2 = this.setting.getStr("host", str, "127.0.0.1");
        int intValue = this.setting.getInt("port", str, 6379).intValue();
        Setting setting = this.setting;
        int intValue2 = setting.getInt("connectionTimeout", str, setting.getInt("timeout", str, 2000)).intValue();
        Setting setting2 = this.setting;
        this.pool = new JedisPool(jedisPoolConfig, str2, intValue, intValue2, setting2.getInt("soTimeout", str, setting2.getInt("timeout", str, 2000)).intValue(), this.setting.getStr("password", str, null), this.setting.getInt("database", str, 0).intValue(), this.setting.getStr("clientName", str, "Hutool"), this.setting.getBool("ssl", str, Boolean.FALSE).booleanValue(), (SSLSocketFactory) null, (SSLParameters) null, (HostnameVerifier) null);
        return this;
    }

    public String setStr(String str, String str2) {
        Jedis jedis = getJedis();
        try {
            String str3 = jedis.set(str, str2);
            jedis.close();
            return str3;
        } catch (Throwable th) {
            try {
                throw th;
            } catch (Throwable th2) {
                if (jedis != null) {
                    try {
                        jedis.close();
                    } catch (Throwable th3) {
                        th.addSuppressed(th3);
                    }
                }
                throw th2;
            }
        }
    }

    public RedisDS(String str) {
        this(null, str);
    }

    public static RedisDS create(String str) {
        return new RedisDS(str);
    }

    public RedisDS(Setting setting, String str) {
        this.setting = setting;
        init(str);
    }

    public static RedisDS create(Setting setting, String str) {
        return new RedisDS(setting, str);
    }
}